<xsl:include>

magnify-glassThe XSLT <xsl:include> element provides a method to include one stylesheet in another without changing semantics of the included stylesheet.

The <xsl:include> element is a top-level element and must be defined as a child of the xsl:stylesheet declaration. This allows you to reuse stylesheets across an application domain – i.e. a library of common templates to reuse. The <xsl:include> element allows stylesheets to be combined without changing the semantics of the included stylesheet – The fact that a stylesheet is included does not affect how the template rules are processed. Compare this to the <xsl:import> element for the difference – import allows you to override functionality – which is substantially different from the <xsl:include> element.

A stylesheet may not include itself directly or indirectly. An XSL processor will throw an error if it detects a cyclic reference like this (if it is implemented correctly).


Syntax

<!-- top-level-element -->
<xsl:include
href = uri-reference />

Attributes

AttributeDescription
hrefA URI reference which identifies and locates a stylesheet to be included. Relative or absolute URI’s are allowed; however, the relative URI is resolved relative to the base of the <xsl:include> element.

Examples

<xsl:include href="common-library.xsl" />

Posted in XSLT and tagged .

Leave a Reply