XmlSchemaCollection.Add Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds the given schema into the schema collection.
Overloads
Add(XmlSchema) |
Adds the XmlSchema to the collection. |
Add(XmlSchemaCollection) |
Adds all the namespaces defined in the given collection (including their associated schemas) to this collection. |
Add(String, String) |
Adds the schema located by the given URL into the schema collection. |
Add(String, XmlReader) |
Adds the schema contained in the XmlReader to the schema collection. |
Add(XmlSchema, XmlResolver) |
Adds the XmlSchema to the collection. The specified XmlResolver is used to resolve any external references. |
Add(String, XmlReader, XmlResolver) |
Adds the schema contained in the XmlReader to the schema collection. The specified XmlResolver is used to resolve any external resources. |
Remarks
Important
The XmlSchemaCollection class is obsolete in .NET Framework version 2.0 and has been replaced by the XmlSchemaSet class.
Add(XmlSchema)
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
Adds the XmlSchema to the collection.
public:
System::Xml::Schema::XmlSchema ^ Add(System::Xml::Schema::XmlSchema ^ schema);
public System.Xml.Schema.XmlSchema? Add(System.Xml.Schema.XmlSchema schema);
public System.Xml.Schema.XmlSchema Add(System.Xml.Schema.XmlSchema schema);
member this.Add : System.Xml.Schema.XmlSchema -> System.Xml.Schema.XmlSchema
Public Function Add (schema As XmlSchema) As XmlSchema
Parameters
- schema
- XmlSchema
The XmlSchema
to add to the collection.
Returns
The XmlSchema
object.
Remarks
The targetNamespace
attribute is used to identify this schema.
If the schema being added contains references to other namespaces (through include
and import
elements), the trust level of the application determines how these other namespaces are resolved. (In the .NET Framework version 1.0, a default XmlUrlResolver was always used).
Fully trusted code:
A default XmlUrlResolver
with no user credentials is used to resolve any external resources. The schemas for these other namespaces are loaded for validation purposes only. Unlike the original schema, these other schemas are not explicitly added to the schema collection. As a result, they are not accessible using any of the collection methods or properties. If these external resources are located on a network resource that requires authentication, use an overload that takes an XmlResolver as one of its arguments and specify an XmlResolver
with the necessary credentials.
Semi-trusted code:
External references are not resolved.
Note
If the XmlSchemaCollection
is being accessed using the XmlValidatingReader.Schemas property, the Add
method uses the XmlResolver
specified by the XmlValidatingReader.XmlResolver property.
Important
The XmlSchemaCollection class is obsolete in .NET Framework version 2.0 and has been replaced by the XmlSchemaSet class.
See also
Applies to
Add(XmlSchemaCollection)
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
Adds all the namespaces defined in the given collection (including their associated schemas) to this collection.
public:
void Add(System::Xml::Schema::XmlSchemaCollection ^ schema);
public void Add(System.Xml.Schema.XmlSchemaCollection schema);
member this.Add : System.Xml.Schema.XmlSchemaCollection -> unit
Public Sub Add (schema As XmlSchemaCollection)
Parameters
- schema
- XmlSchemaCollection
The XmlSchemaCollection
you want to add to this collection.
Remarks
If the schema being added contains references to other namespaces (through include
and import
elements or the x-schema
attribute), the trust level of the application determines how these other namespaces are resolved. (In the .NET Framework version 1.0, a default XmlUrlResolver was always used).
Fully trusted code:
A default XmlUrlResolver
with no user credentials is used to resolve any external resources. The schemas for these other namespaces are loaded for validation purposes only. Unlike the original schema, these other schemas are not explicitly added to the schema collection. As a result, they are not accessible using any of the collection methods or properties. If these external resources are located on a network resource that requires authentication, use an overload that takes an XmlResolver as one of its arguments and specify an XmlResolver
with the necessary credentials.
Semi-trusted code:
External references are not resolved.
Note
If the XmlSchemaCollection
is being accessed using the XmlValidatingReader.Schemas property, the Add
method uses the XmlResolver
specified by the XmlValidatingReader.XmlResolver property.
Important
The XmlSchemaCollection class is obsolete in .NET Framework version 2.0 and has been replaced by the XmlSchemaSet class.
Applies to
Add(String, String)
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
Adds the schema located by the given URL into the schema collection.
public:
System::Xml::Schema::XmlSchema ^ Add(System::String ^ ns, System::String ^ uri);
public System.Xml.Schema.XmlSchema? Add(string? ns, string uri);
public System.Xml.Schema.XmlSchema Add(string ns, string uri);
member this.Add : string * string -> System.Xml.Schema.XmlSchema
Public Function Add (ns As String, uri As String) As XmlSchema
Parameters
- ns
- String
The namespace URI associated with the schema. For XML Schemas, this will typically be the targetNamespace
.
- uri
- String
The URL that specifies the schema to load.
Returns
The XmlSchema added to the schema collection; null
if the schema being added is an XDR schema or if there are compilation errors in the schema.
Exceptions
The schema is not a valid schema.
Remarks
If ns
has already been associated with another schema in the collection, the schema being added replaces the original schema in the collection. For example, in the following C# code, authors.xsd is removed from the collection and names.xsd is added.
schemaColl.Add("urn:author", "authors.xsd");
schemaColl.Add("urn:author", "names.xsd");
If ns
is null
and the schema being added is an XML Schema, the Add
method uses the targetNamespace
defined in the XML Schema to identify the schema in the collection. If the schema being added contains references to other namespaces (through include
and import
elements or the x-schema
attribute), the trust level of the application determines how these other namespaces are resolved. (In the .NET Framework version 1.0, a default XmlUrlResolver was always used).
Fully trusted code:
A default XmlUrlResolver
with no user credentials is used to resolve any external resources. The schemas for these other namespaces are loaded for validation purposes only. Unlike the original schema, these other schemas are not explicitly added to the schema collection. As a result, they are not accessible using any of the collection methods or properties. If these external resources are located on a network resource that requires authentication, use an overload that takes an XmlResolver as one of its arguments and specify an XmlResolver
with the necessary credentials.
Semi-trusted code:
External references are not resolved.
Note
If the XmlSchemaCollection
is being accessed using the XmlValidatingReader.Schemas property, the Add
method uses the XmlResolver
specified by the XmlValidatingReader.XmlResolver property.
Important
The XmlSchemaCollection class is obsolete in .NET Framework version 2.0 and has been replaced by the XmlSchemaSet class.
Applies to
Add(String, XmlReader)
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
Adds the schema contained in the XmlReader to the schema collection.
public:
System::Xml::Schema::XmlSchema ^ Add(System::String ^ ns, System::Xml::XmlReader ^ reader);
public System.Xml.Schema.XmlSchema? Add(string? ns, System.Xml.XmlReader reader);
public System.Xml.Schema.XmlSchema Add(string ns, System.Xml.XmlReader reader);
member this.Add : string * System.Xml.XmlReader -> System.Xml.Schema.XmlSchema
Public Function Add (ns As String, reader As XmlReader) As XmlSchema
Parameters
- ns
- String
The namespace URI associated with the schema. For XML Schemas, this will typically be the targetNamespace
.
Returns
The XmlSchema added to the schema collection; null
if the schema being added is an XDR schema or if there are compilation errors in the schema.
Exceptions
The schema is not a valid schema.
Remarks
If ns
has already been associated with another schema in the collection, the schema being added replaces the original schema in the collection.
If ns
is null
and the schema being added is an XML Schema, the Add
method uses the targetNamespace
defined in the XML Schema to identify the schema in the collection.
If the schema being added contains references to other namespaces (through include
and import
elements or the x-schema
attribute), the trust level of the application determines how these other namespaces are resolved. (In the .NET Framework version 1.0, a default XmlUrlResolver was always used).
Fully trusted code:
A default XmlUrlResolver
with no user credentials is used to resolve any external resources. The schemas for these other namespaces are loaded for validation purposes only. Unlike the original schema, these other schemas are not explicitly added to the schema collection. As a result, they are not accessible using any of the collection methods or properties. If these external resources are located on a network resource that requires authentication, use an overload that takes an XmlResolver as one of its arguments and specify an XmlResolver
with the necessary credentials.
Semi-trusted code:
External references are not resolved.
Note
If the XmlSchemaCollection
is being accessed using the XmlValidatingReader.Schemas property, the Add
method uses the XmlResolver
specified by the XmlValidatingReader.XmlResolver property.
Important
The XmlSchemaCollection class is obsolete in .NET Framework version 2.0 and has been replaced by the XmlSchemaSet class.
Applies to
Add(XmlSchema, XmlResolver)
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
Adds the XmlSchema to the collection. The specified XmlResolver is used to resolve any external references.
public:
System::Xml::Schema::XmlSchema ^ Add(System::Xml::Schema::XmlSchema ^ schema, System::Xml::XmlResolver ^ resolver);
public System.Xml.Schema.XmlSchema? Add(System.Xml.Schema.XmlSchema schema, System.Xml.XmlResolver? resolver);
public System.Xml.Schema.XmlSchema Add(System.Xml.Schema.XmlSchema schema, System.Xml.XmlResolver resolver);
member this.Add : System.Xml.Schema.XmlSchema * System.Xml.XmlResolver -> System.Xml.Schema.XmlSchema
Public Function Add (schema As XmlSchema, resolver As XmlResolver) As XmlSchema
Parameters
- schema
- XmlSchema
The XmlSchema
to add to the collection.
- resolver
- XmlResolver
The XmlResolver used to resolve namespaces referenced in include
and import
elements. If this is null
, external references are not resolved.
Returns
The XmlSchema
added to the schema collection.
Exceptions
The schema is not a valid schema.
Remarks
The targetNamespace
attribute is used to identify this schema.
If the schema contains include
and import
elements that reference other namespaces, the schemas for these other namespaces are loaded for validation purposes only. Unlike the original schema, these other schemas are not explicitly added to the schema collection. As a result, they are not accessible using any of the collection methods or properties.
Important
The XmlSchemaCollection class is obsolete and has been replaced by the XmlSchemaSet class.
See also
Applies to
Add(String, XmlReader, XmlResolver)
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
- Source:
- XmlSchemaCollection.cs
Adds the schema contained in the XmlReader to the schema collection. The specified XmlResolver is used to resolve any external resources.
public:
System::Xml::Schema::XmlSchema ^ Add(System::String ^ ns, System::Xml::XmlReader ^ reader, System::Xml::XmlResolver ^ resolver);
public System.Xml.Schema.XmlSchema? Add(string? ns, System.Xml.XmlReader reader, System.Xml.XmlResolver? resolver);
public System.Xml.Schema.XmlSchema Add(string ns, System.Xml.XmlReader reader, System.Xml.XmlResolver resolver);
member this.Add : string * System.Xml.XmlReader * System.Xml.XmlResolver -> System.Xml.Schema.XmlSchema
Public Function Add (ns As String, reader As XmlReader, resolver As XmlResolver) As XmlSchema
Parameters
- ns
- String
The namespace URI associated with the schema. For XML Schemas, this will typically be the targetNamespace
.
- resolver
- XmlResolver
The XmlResolver used to resolve namespaces referenced in include
and import
elements or x-schema
attribute (XDR schemas). If this is null
, external references are not resolved.
Returns
The XmlSchema added to the schema collection; null
if the schema being added is an XDR schema or if there are compilation errors in the schema.
Exceptions
The schema is not a valid schema.
Remarks
If ns
has already been associated with another schema in the collection, the schema being added replaces the original schema in the collection.
If ns
is null
and the schema being added is an XML Schema, the Add
method uses the targetNamespace
attribute defined in the XML Schema to identify the schema in the collection.
If the schema being added contains references to other namespaces (through include
and import
elements or the x-schema
attribute), the schemas for these other namespaces are loaded for validation purposes only. Unlike the original schema, these other schemas are not explicitly added to the schema collection. As a result, they are not accessible using any of the collection methods or properties.
Important
The XmlSchemaCollection class is obsolete in .NET Framework version 2.0 and has been replaced by the XmlSchemaSet class.