Phần tử <xsl:include> của XSLT
Định nghĩa và cách sử dụng
Phần tử <xsl:include> là phần tử cấp cao (top-level element), bao gồm nội dung mẫu biểu của một mẫu biểu vào mẫu biểu khác.
Chú ý:Mẫu biểu được bao gồm (included style sheet) có cùng mức ưu tiên với mẫu biểu bao gồm (including style sheet).
Chú ý:Các phần tử này phải là con của <xsl:stylesheet> hoặc <xsl:transform>.
Cú pháp
<xsl:include href="URI"/>
Thuộc tính
Thuộc tính | Giá trị | Mô tả |
---|---|---|
href | URI | Phải có. Định nghĩa URI của mẫu biểu cần bao gồm. |
Mô hình
Ví dụ 1
Dưới đây là ví dụ bao gồm mẫu biểu được gọi là xslincludefile.xsl:
<?xml version=1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:template match="/"> <xsl:for-each select="COLLECTION/BOOK"> <xsl:apply-templates select="TITLE"/> <xsl:apply-templates select="AUTHOR"/> <xsl:apply-templates select="PUBLISHER"/> <BR/> <!-- add this --> </xsl:for-each> </xsl:template> <xsl:template match="TITLE"> <DIV STYLE="color:blue"> Title: <xsl:value-of select="."/> </DIV> </xsl:template> <xsl:include href="/xsl/xslincludefile.xsl" /> </xsl:stylesheet>