XmlSchemaSet.Add Method (String, XmlReader)
Assembly: System.Xml (in System.Xml.dll)
The schema targetNamespace property, or null to use the targetNamespace specified in the schema.
Before a schema can be added to an XmlSchemaSet, it has to be successfully preprocessed. Preprocessing performs the following basic tasks.
The schema is checked for structural validity according to the rules of W3C XML Schema, but the schema is not fully validated.
References to internal and external schema components are resolved. Any imported or included schemas that are successfully retrieved are also added to the XmlSchemaSet. Imported schemas are added as separate XmlSchema objects, and included schemas are made a part of the including XmlSchema.
The following are important notes to consider when using themethod.
If the XmlReader is not positioned on the root element, an XmlSchemaException is thrown unless the current item is an element. If the current item is an xs:schema element, the schema document is read into the XmlSchemaSet; otherwise, an XmlSchemaException is thrown because the schema is not valid.
If the XmlReader is positioned over a sequence of XML nodes, only the first node in the sequence is added.
The XmlResolver property of the XmlReader is not used to resolve references to namespaces or schema locations in include and import elements. Instead, the XmlResolver property of the XmlSchemaSet is used.
The XmlSchemaSet has the ability to use the target namespace defined in a schema, rather than requiring the target namespace be specified as a parameter when the method is called. Specifying null or String.Empty to the method instructs the XmlSchemaSet to use the target namespace defined in the schema. For an example of this behavior, see the Add method.method of the
The remaining functionality of this method is identical to that of the Add method.
Available since 2.0