?
本文檔使用 php中文網(wǎng)手冊 發(fā)布
<xsl:import> 元素是頂層元素,用于把一個樣式表中的內(nèi)容導入另一個樣式表中。
注意:被導入的樣式表的優(yōu)先級低于導出的樣式表。
注意:該元素必須是 <xsl:stylesheet> 或 <xsl:transform> 的第一個子節(jié)點。
<xsl:import href="URI"/>
屬性 | 值 | 描述 |
---|---|---|
href | URI | 必需。規(guī)定要導入的樣式表的 URI。 |
假設(shè)您有一個名為 "cdcatalog_ex3.xsl" 的樣式表:
<?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="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <tr> <td><xsl:value-of select="catalog/cd/title"/></td> <td><xsl:value-of select="catalog/cd/artist"/></td> </tr> </table> </body> </html> </xsl:template> </xsl:stylesheet>
第二個名為 "cdcatalog_import.xsl" 的樣式表會導入 "cdcatalog_ex3.xsl":
<?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="cdcatalog_ex3.xsl"/> <xsl:template match="/"> <xsl:apply-imports/> </xsl:template> </xsl:stylesheet>
注意:該實例無法在 Netscape 6 運行,因為 Netscape 6 不支持 <xsl:apply-imports> 元素!