Freigeben über


Include Element Binding Support 

The .NET Framework provides partial binding support for the <include> element.

When generating source code from the <include> element, Xsd.exe locates an included XSD document as an absolute file-system path specified via the schemaLocation attribute.

Explanation

The <include> element resembles the <import> element. Both elements appear as children of the root <schema> element; they must appear before any other children. Both pull in a separate <schema> definition, typically defined in another .xsd file. There is one key distinction, as follows:

  • <import>: Imports schema definitions and declarations within a separate namespace specified via the namespace attribute.

  • <include>: Includes additional schema definitions and declarations within the same namespace specified as the targetNamespace for the existing XML Schema definition.

An XML Schema definition that uses <include> elements is syntactically equivalent to an XML Schema definition in which the included definitions appear directly.

When generating XML Schema documents from a set of classes in an assembly, Xsd.exe creates only one .xsd file per target namespace. In other words, no two .xsd files generated have the same value for the targetNamespace attribute of the root <schema> element. Therefore, the <include> element is never generated. A developer can always manually break up a generated .xsd file into multiple files by employing the <include> element.

When generating source code from an XML Schema document, Xsd.exe recognizes the <include> element. Included XSD documents should not be passed as extra arguments to Xsd.exe. Instead, they are located via the schemaLocation attribute. The attribute value should be an absolute file-system path.

The following example shows a valid schemaLocation value:

<xsd:include schemaLocation="c:\\projectRoot\\source\\xsd\\included1.xsd" />

Note

Xsd.exe ignores the schemaLocation attribute when it appears in the <import> element. Instead, for Xsd.exe any imported files are specified as additional command-line arguments. See Import Element Binding Support.

Possible Attributes Binding Support

id

The Xsd.exe utility ignores the id attribute, which is intended to provide a unique identifier.

schemaLocation

See the preceding text.

Possible parent elements: <schema>

Possible child elements: <annotation>

See Also

Reference

XmlSchemaInclude