This documentation is archived and is not being maintained.

Import Element Binding Support

This topic is specific to a legacy technology. XML Web services and XML Web service clients should now be created using Windows Communication Foundation .

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

For the <import> element, the Xsd.exe tool ignores the schemaLocation attribute, expecting imported files as additional command-line arguments.

The <import> element resembles the <include> 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 using the namespace attribute.

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

The following is an example of the <import> element's usage:

<xsd:import  namespace="" schemaLocation="" />

The schemaLocation attribute is intended to specify the location of the imported .xsd file. However, 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.

The generated source file gets the name of the last XSD file passed as an argument. For example, the following command-line invocation of Xsd.exe:

xsd importedAttribute.xsd attributeRef.xsd /classes /language:CS

The resulting source file is given the name attributeRef.cs.

Xsd.exe does use the schemaLocation attribute when it appears in the <include> element. When generating source code from an XML Schema document, Xsd.exe recognizes an absolute file-system path for the value. For more information, see Include Element Binding Support.

The namespace attribute is used to identify the imported target namespace, which must differ from the target namespace of the XSD document doing the importing (the one that contains the <import> element).

When generating source code from an XML Schema document, Xsd.exe sets a Namespace property on the .NET Framework attribute that is applied to each type or field that corresponds to an entity that is imported. Even when no extra namespaces are imported, Xsd.exe sets the Namespace property of the following two attributes to that of the original XSD document's target namespace:

An imported namespace can be specified using the Namespace property of certain XML-related attribute classes. The property appears as follows:

Possible Attributes Binding Support


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


See the preceding Namespace Attribute section.


See the preceding SchemaLocation Attribute section.

Possible parent elements: <schema>

Possible child elements: <annotation>