Name
<xsl:include> — Allows you to include another XSLT stylesheet. This element allows you to put common transformations in a separate stylesheet, then include the templates from that stylesheet at any time. Unlike <xsl:import>
, all templates included with <xsl:include>
have the same priority as those in the including stylesheet. Another difference is that <xsl:include>
can appear anywhere in a stylesheet, while <xsl:import>
must appear at the beginning.
Category
Top-level element
Required Attributes
- href
Defines the URI of the included stylesheet.
Optional Attributes
None.
Content
None. <xsl:include>
is an empty element.
Appears in
<xsl:include>
is a top-level element and can appear only as a child of <xsl:stylesheet>
.
Defined in
XSLT section 2.6.1, Stylesheet Inclusion.
Example
The <xsl:include>
element is a good way
to break your stylesheets into smaller pieces. (Those smaller pieces
are often easier to reuse.) In our case study (see Chapter 9), we had a number of different stylesheets, each
of which contained templates for a particular purpose. Here’s how our
<xsl:include>
elements look:
<xsl:include href="toot-o-matic-variables.xsl"/> <xsl:include href="xslt-utilities.xsl"/> <xsl:include href="dw-style.xsl"/> <xsl:include href="build-main-index.xsl"/> <xsl:include href="build-section-indexes.xsl"/> <xsl:include href="build-individual-panels.xsl"/> <xsl:include href="build-graphics.xsl"/> <xsl:include href="build-pdf-file.xsl"/> <xsl:include href="build-zip-file.xsl"/>
Segmenting your stylesheets ...
Get XSLT 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.