XSLT <xsl:include> Element

Definition and Usage

<xsl:include> element is a top-level element (top-level element), which includes the style sheet content of one style sheet into another style sheet.

Note:The included stylesheet (included style sheet) has the same priority as the including stylesheet (including style sheet).

Note:This element must be a child of <xsl:stylesheet> or <xsl:transform>.

Syntax

<xsl:include href="URI"/>

Attribute

Attribute Value Description
href URI Required. Specifies the URI of the stylesheet to be included.

Instance

Example 1

The following example includes a stylesheet named xslincludefile.xsl:

<?xml version=1.0'?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
   <xsl:for-each select="COLLECTION/BOOK">
      <xsl:apply-templates select="TITLE"/>
      <xsl:apply-templates select="AUTHOR"/>
      <xsl:apply-templates select="PUBLISHER"/>
      <BR/>  <!-- add this -->
   </xsl:for-each>
</xsl:template>
<xsl:template match="TITLE">
  <DIV STYLE="color:blue">
    Title: <xsl:value-of select="."/>
  </DIV>
</xsl:template>
<xsl:include href="/xsl/xslincludefile.xsl" />
</xsl:stylesheet>

View XSL File,View Included XSL File,View Results.