XSLT <xsl:apply-imports>Element


XSLT 元素参考手册Complete XSLT Element Reference

Definition and Usage

The <xsl:apply-imports> element applies a template rule from an imported style sheet.

Template rules in imported style sheets have a lower priority than template rules in the main style sheet. If you want to use a template rule from an imported style sheet instead of an equivalent rule in the main style sheet, you use the <xsl:apply-imports> element.


Syntax

<xsl:apply-imports/>

Attributes

None

Example

Suppose we have a style sheet named "standard.xsl" that contains a template rule 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 style sheet can import "standard.xsl" and modify the message element, as follows:

<?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.html"/>

<xsl:template match="message">
<div style="border:solid blue">
<xsl:apply-imports/>
</div>
</xsl:template>

</xsl:stylesheet>

The result will transform a message into a form element:

<div style="border:solid blue"><h2>...</h2></div>


XSLT 元素参考手册Complete XSLT Element Reference Other Extensions