Tamino XML Server Version 9.7
 —  Tamino XML Schema Reference Guide  —

xs:import

Purpose

This element is used for schema composition across multiple namespaces. Its purpose is to make definitions from a different namespace visible in the importing schema.

The schema to be imported must already be defined in the Tamino database.

For example, to import a schema named ImportedSchema.tsd, specify an xs:import element with a schemaLocation attribute like this:

../<collection name>/ImportedSchema.tsd

where <collection name> is the name of the collection containing the referenced schema.

Notes:

  1. The namespace attribute and the schemaLocation attribute are not mutually exclusive.
  2. Multiple xs:import elements are allowed under one xs:schema element. They may be necessary to import multiple namespaces into one schema.
Parent element xs:schema
Child elements None
Attributes namespace, schemaLocation
Restriction

The targetNamespace of the importing schema and the targetNamespace of the imported schema must not be the same. In particular, only one of these may have the value "absent".

Attributes
Name Type Description
namespace xs:anyURI

This attribute specifies the URI of the namespace that is to be imported. It must match the targetNamespace attribute of the imported schema.

If this attribute is not specified, the schemaLocation attribute must be specified, and it must refer to a schema without a target namespace.

schemaLocation xs:anyURI

This attribute specifies the location of the schema that is to be imported.

To locate a schema stored in the same database, the structure of the schemaLocation attribute can be any of the following:

  • ../collectionName/schemaName

  • ./schemaName

  • schemaName

Note:
./schemaName and schemaName are always equivalent.

Example 1

This example shows the use of the xs:import element. It shows how to import a namespace with the prefix html: to be able to define a documentation paragraph in a schema document according to XHTML (as defined in http://www.w3.org/1999/xhtml/):

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tsd="http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition"
           xmlns:html="http://www.w3.org/1999/xhtml"
           targetNamespace="http://www.w3.org/2001/XMLSchema">

 <xs:import namespace="http://www.w3.org/1999/xhtml"/>
 .
 .
 .
 <xs:complexType name="myType">
  <xs:sequence>
   <xs:element ref="html:p" minOccurs="0"/>
  </xs:sequence>
 .
 .
 .
 </xs:complexType>
 .
 .
 .

Example 2: namespace and schemaLocation attributes

The following schema illustrates the simultaneous use of the namespace and schemaLocation attributes of the xs:import element:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
  targetNamespace="http://www.softwareag.com/tamino/doc/examples/models/jazz/encyclopedia"
  xmlns:e="http://www.softwareag.com/tamino/doc/examples/models/jazz/encyclopedia"
  xmlns:i="http://www.softwareag.com/tamino/doc/examples/models/jazz/instruments"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:tsd="http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified">
  <xs:import
		 namespace="http://www.softwareag.com/tamino/doc/examples/models/instruments"
	  schemaLocation="../commonMusic/instruments.xsd"/>
    <xs:element name="e:jazzMusician">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="e:name" type="e:tName"/>
          .
          .
          .
          <xs:element name="e:plays" minOccurs="0" maxOccurs="unbounded">
            <xs:complexType>
              <xs:choice>
                <xs:element ref="i:saxophone"/>
              </xs:choice>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
								.
								.
        .
      </xs:complexType>
    </xs:element>
    .
    .
    .
</xs:schema>

This example schema defines three additional namespaces: e,xs and tsd. It uses a targetNamespace declaration in the xs:schema element.

Note:
The schema instruments.xsd was previously defined in the "commonMusic" collection (which is a sibling of the current collection) and is referenced via a relative value in the schemaLocation attribute.

Top of page