August 2001
Intermediate to advanced
480 pages
11h 16m
English
<xsl:import> — Allows you to import the templates found in another XSLT stylesheet. Unlike <xsl:include>, all templates imported with <xsl:import> have a lower priority than those in the including stylesheet. Another difference between <xsl:include> and <xsl:import> is that <xsl:include> can appear anywhere in a stylesheet, while <xsl:import> can appear only at the beginning.
Top-level element
Defines the URI of the imported stylesheet.
None.
None. <xsl:import> is an empty element.
<xsl:import> is a top-level element and can appear only as a child of <xsl:stylesheet>.
XSLT section 2.6.2, Stylesheet Import.
Here is a simple stylesheet that we’ll import:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:variable name="newline"> <xsl:text> </xsl:text> </xsl:variable> <xsl:template match="/"> <xsl:value-of select="$newline"/> <xsl:apply-templates select="list/title"/> <xsl:apply-templates select="list/listitem"/> </xsl:template> <xsl:template match="title"> <xsl:value-of select="."/> <xsl:text>: </xsl:text> <xsl:value-of select="$newline"/> <xsl:value-of select="$newline"/> </xsl:template> <xsl:template match="listitem"> <xsl:text>HERE IS LISTITEM NUMBER </xsl:text> <xsl:value-of select="position()"/> <xsl:text>: </xsl:text> <xsl:value-of select="."/> <xsl:value-of select="$newline"/> </xsl:template> </xsl:stylesheet> ...