Name

xs:import

Synopsis

<xs:import
  id = "ID"
  namespace = "anyURI"
  schemaLocation = "anyURI" >
  <!-- ( xs:annotation? ) -->
</xs:import>

Since each schema document has exactly one target namespace, the top-level xs:import element is needed to create schemas for documents that involve multiple namespaces. The namespace attribute contains the namespace URI for the application that the imported schema describes. If the imported schema describes elements and types in no namespace, then the namespace attribute is omitted. The optional schemaLocation attribute contains a relative or absolute URL pointing to the actual location of the schema document to import.

There is no limit to import depth. Schema A can import schema B, which itself imports schema C and schema D. In such a case, schema A can use definitions and declarations from all four schemas. Even recursion (schema A imports schema B, which imports schema A) is not prohibited. Since the imported schema must describe a different target namespace than the importing schema, conflicts between definitions in the multiple schemas are normally not a problem. However, if conflicts do arise, then the schema is in error and cannot be used. There are no precedence rules for choosing between multiple conflicting definitions or declarations.

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.