XSLT <xsl: import>
❮ Toàn bộ tham chiếu phần tử XSLT
Định nghĩa và Cách sử dụng
Phần tử <xsl: import> là phần tử cấp cao nhất được sử dụng để nhập nội dung của một biểu định kiểu sang một biểu định kiểu khác.
Lưu ý: Biểu định kiểu đã nhập có mức độ ưu tiên thấp hơn biểu định kiểu nhập.
Lưu ý: Phần tử này phải xuất hiện dưới dạng nút con đầu tiên của <xsl: stylesheet> hoặc <xsl: converter>.
Cú pháp
<xsl:import href="URI"/>
Thuộc tính
Attribute | Value | Description |
---|---|---|
href | URI | Required. Specifies the URI of the style sheet to import |
ví dụ 1
Giả sử bạn có một biểu định kiểu có tên "cdcatalog_ex3.xsl":
<?xml version="1.0" encoding="UTF-8"?>
<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>
Biểu định kiểu thứ hai có tên "cdcatalog_import.xsl" nhập "cdcatalog_ex3.xsl":
<?xml version="1.0" encoding="UTF-8"?>
<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>
❮ Toàn bộ tham chiếu phần tử XSLT