XSLT <xsl:apply-imports> Element
Definition and Usage
The <xsl:apply-imports> element can apply template rules from the imported stylesheet.
The priority of template rules imported from a stylesheet is lower than that of the main stylesheet. If you want to use a template rule from the imported stylesheet instead of an equivalent rule from the main stylesheet, you will use the <xsl:apply-imports> element.
Syntax
<xsl:apply-imports/>
Attributes
None
Example
Assuming we have a stylesheet named "standard.xsl" that contains template rules for the "message" element:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="message"> <h2><xsl:apply-templates/></h2> </xsl:template> </xsl:stylesheet>
Another stylesheet can import "standard.xsl" and modify "message", like this:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:import href="standard.xsl"/> <xsl:template match="message"> <div style="border:solid blue"> <xsl:apply-imports/> </div> </xsl:template> </xsl:stylesheet>
The result is: a message will be converted into a tabular element:
<div style="border:solid blue"><h2>...</h2></div>