<xsd:import> Element
Identifies a namespace whose schema components are referenced by the containing schema.
<import
id = ID
namespace = anyURI
schemaLocation = anyURI
{any attributes with non-schema Namespace}...>
Content: (annotation?)
</import>
Attributes
id
The ID of this element. The id value must be of type ID and be unique within the document containing this element.Optional.
namespace
The URI reference to the namespace to import.The namespace attribute indicates that the containing schema document may contain qualified references to schema components in that namespace (through one or more prefixes declared with xmlns attributes).
If this attribute is absent, the containing schema can contain unqualified references to components in the imported namespace.
Optional.
schemaLocation
The URI reference to the location of a schema document for the imported namespace.If this attribute is absent, the author is allowing the identification of the schema for the imported namespace to be determined by the XML document that is an instance of the containing schema or the user or application that is processing it.
Optional.
Element Information
Number of occurrences |
Unlimited |
Parent elements |
|
Contents |
Remarks
The difference between the include element and the import element is that import element allows references to schema components from schema documents with different target namespaces and the include element adds the schema components from other schema documents that have the same target namespace (or no specified target namespace) to the containing schema. In short, the import element allows you to use schema components from any schema; the include element allows you to add all the components of an included schema to the containing schema.
Example
The following example shows importing a namespace.
<?xml version="1.0"?>
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.w3.org/2001/05/XMLInfoset" xmlns="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.example.com/IPO" />
<xs:include schemaLocation="example.xsd" />
</xs:schema>
Other Resources
For more information see the W3C XML Schema Part 1: Structures Recommendation at www.w3.org/TR/2001/REC-xmlschema-1-20010502/\#element-all.
See Also
Reference
XML Schemas (XSD) Reference
XML Schema Elements
<xsd:include> Element