?
本文檔使用 php中文網(wǎng)手冊 發(fā)布
<xsl:apply-imports> 元素可應用來自導入樣式表中的模版規(guī)則。
導入樣式表中的模版規(guī)則的優(yōu)先級要比主樣式表中的模版規(guī)則要低。如果您希望使用導入樣式表中的某條模版規(guī)則,而不是主樣式表中的某條等價規(guī)則,就會用到 <xsl:apply-imports> 元素。
<xsl:apply-imports/>
無
假設我們有一個名為 "standard.xsl" 的樣式表,其中包含用于 message 元素的模版規(guī)則:
<?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>
另一個樣式表能夠導入 "standard.xsl",并修改 message 元素,如下所示:
<?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>
結果將會把一條消息轉換到表單元素中:
<div style="border:solid blue"><h2>...</h2></div>