public class XmlSchemaInclude : XmlSchemaExternal
|
The included schema must have the same target namespace as the containing schema document.
OR
The included schema cannot have a specified targetNamespace; the targetNamespace attribute must be null.
XmlSchemaInclude adds all the schema components from included schemas that have the same target namespace (or no specified target namespace) to the containing schema.
using System; using System.Collections; using System.IO; using System.Xml; using System.Xml.Xsl; using System.Xml.Schema; public class ImportIncludeSample { public static void ValidationCallBack(object sender, ValidationEventArgs args ){ if(args.Severity == XmlSeverityType.Warning) Console.Write("WARNING: "); else if(args.Severity == XmlSeverityType.Error) Console.Write("ERROR: "); Console.WriteLine(args.Message); } public static void Main() { XmlSchema schema = new XmlSchema(); schema.ElementFormDefault = XmlSchemaForm.Qualified; schema.TargetNamespace = "http://www.w3.org/2001/05/XMLInfoset"; // <xs:import namespace="http://www.example.com/IPO" /> XmlSchemaImport import = new XmlSchemaImport(); import.Namespace = "http://www.example.com/IPO"; schema.Includes.Add(import); // <xs:include schemaLocation="example.xsd" /> XmlSchemaInclude include = new XmlSchemaInclude(); include.SchemaLocation = "example.xsd"; schema.Includes.Add(include); schema.Compile(new ValidationEventHandler(ValidationCallBack)); XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); schema.Write(Console.Out, nsmgr); }/* Main() */ } //ImportIncludeSample
The following XML is generated for this code example.
<?xml version="1.0" encoding="IBM437"?> <schema elementFormDefault="qualified" targetNamespace="http://www.w3.org/2001/05/XMLInfoset" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://www.example.com/IPO" /> <include schemaLocation="example.xsd" /> </schema>
ctor #1 | Default constructor. This constructor is called by derived class constructors to initialize state in this type. |
Annotation | Read-write Gets or sets the annotation property. |
Id (inherited from System.Xml.Schema.XmlSchemaExternal) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaExternal.Id Gets or sets the string id. |
LineNumber (inherited from System.Xml.Schema.XmlSchemaObject) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaObject.LineNumber Gets or sets the line number in the file to which the schema element refers. |
LinePosition (inherited from System.Xml.Schema.XmlSchemaObject) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaObject.LinePosition Gets or sets the line position in the file to which the schema element refers. |
Namespaces (inherited from System.Xml.Schema.XmlSchemaObject) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaObject.Namespaces |
Schema (inherited from System.Xml.Schema.XmlSchemaExternal) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaExternal.Schema Gets or sets the XmlSchema for the referenced schema. |
SchemaLocation (inherited from System.Xml.Schema.XmlSchemaExternal) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaExternal.SchemaLocation Gets or sets the URI location for the schema, which tells the schema processor where the schema physically resides. |
SourceUri (inherited from System.Xml.Schema.XmlSchemaObject) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaObject.SourceUri Gets or sets the source location for the file that loaded the schema. |
UnhandledAttributes (inherited from System.Xml.Schema.XmlSchemaExternal) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaExternal.UnhandledAttributes Gets and sets the qualified attributes which do not belong to the schema target namespace. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public XmlSchemaInclude(); |
public XmlSchemaAnnotation Annotation {get; set;}
|
public string Id {get; set;}
|
public int LineNumber {get; set;}
|
public int LinePosition {get; set;}
|
public XmlSerializerNamespaces Namespaces {get; set;}
|
public XmlSchema Schema {get; set;}
|
public string SchemaLocation {get; set;}
|
Included schemas use this attribute as the URI reference to the location of a schema document that should be included in the target namespace of the containing schema.
public string SourceUri {get; set;}
|
public XmlAttribute[] UnhandledAttributes {get; set;}
|
~XmlSchemaInclude(); |
public virtual int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
public virtual string ToString(); |