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 ../<collection name>/ImportedSchema.tsd where <collection name> is the name of the collection containing the referenced schema. Notes:
|
Parent element | xs:schema |
Child elements | None |
Attributes | namespace ,
schemaLocation |
Restriction |
The |
Name | Type | Description |
---|---|---|
namespace |
xs:anyURI |
This attribute specifies the URI of the namespace that is to
be imported. It must match the If this attribute is not specified, the
|
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
Note: |
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> . . .
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.