Name

[2.0 – Schema] <xsl:import-schema>

Allows you to import an XML Schema. The schema is imported and processed before any input documents are processed. This allows you to define datatypes and validation rules before the XSLT processor begins to transform the input document. This element is only supported by schema-aware XSLT 2.0 processors.

Category

Top-level element.

Required Attributes

None.

Optional Attributes

namespace

The namespace used by the imported schema. Any templates or XPath functions can use this namespace to indicate that an element or value is defined by that schema.

schema-location

A URI reference to the schema document. If a stylesheet imports and uses a schema, it is a fatal error if the schema can’t be found. An XSLT processor is allowed to ignore the error if you import a schema but never use it.

The <xsl:import-schema> element can include the <xs:schema> element itself. It is a fatal error if an <xsl:import-schema> element contains a <xs:schema> and has a schema-location attribute.

Content

None of the elements from the XSLT namespace can appear inside <xsl:import-schema>. If <xsl:import-schema> has any contents, it will likely be an <xs:schema> element that in turn defines datatypes and elements. Again, it is an error for an <xsl:import-schema> element to contain content and have a schema-location attribute.

Appears in

<xsl:import-schema> is a top-level element and can only appear as a child of <xsl:stylesheet>.

Defined in

[2.0] XSLT section 3.14, “Importing Schema Components.” ...

Get XSLT, 2nd 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.