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>
Optional.
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.
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.
Number of occurrences | Unlimited |
Parent elements | schema |
Contents | annotation |
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.
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>
XML Schema Reference (XSD) | XML Schema Elements | include
For more information, see the W3C XML Schema Part 1: Structures Recommendation at http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-import.