Includes another XSLT file.
<xsl:include href = "uri-reference"/>
Number of occurrences | Unlimited |
Parent elements | xsl:stylesheet, xsl:transform |
Child elements | (No child elements) |
An XSLT file can include another XSLT file using the <xsl:include>
element. The href
attribute value is a URI reference identifying the file to be included. The relative URI is resolved with relation to the base URI of the <xsl:include>
element.
The <xsl:include>
element is only allowed as the child of the <xsl:stylesheet>
element.
Inclusions are processed in Microsoft® XML Core Services (MSXML) 5.0 for Microsoft Office as if they occurred at the tree level. Note that this is not the same as the Document Object Model (DOM) view of the XML tree. The resource located by the href
attribute value is parsed as an XML document, and the children of the <xsl:stylesheet>
element in this document replace the <xsl:include>
element in the including document. Unlike with <xsl:import>
, the included template rules have the same import precedence as the ones in the including style sheet. Thus, when the including and the included style sheets both contain a template rule for one element, which template is called depends onthe document order. If the template in the including stylesheet follows the included template, the former is invoked. Otherwise, the latter is invoked.
An error occurs if an XSLT file directly or indirectly includes itself.
Including an XSLT file multiple times can cause errors because of duplicate definitions. Such multiple inclusions are less obvious when they are indirect. For example, A, B, C, and D are all XSLT files. Files B, C, and D include other XSLT files, as follows:
Then, the XSLT file, D, will indirectly include the XSLT file, A, twice. You can avoid this error by separating everything in B (other than the inclusion of A) into a separate XSLT file, B1, and changing B to include B1 and A. Then, use this same approach on C and, finally, change D to include A, B1, C1.
The following topic provides an example of <xsl:include>
.