XSLT <xsl:import>
❮ ทำการอ้างอิงองค์ประกอบ XSLT ให้สมบูรณ์
ความหมายและการใช้งาน
<xsl:import> องค์ประกอบเป็นองค์ประกอบระดับบนสุดที่ใช้ในการนำเข้าเนื้อหาของสไตล์ชีตหนึ่งไปยังอีกสไตล์หนึ่ง
หมายเหตุ:สไตล์ชีตที่นำเข้ามีลำดับความสำคัญต่ำกว่าสไตล์ชีตที่นำเข้า
หมายเหตุ:องค์ประกอบนี้ต้องปรากฏเป็นโหนดย่อยแรกของ <xsl:stylesheet> หรือ <xsl:transform>
ไวยากรณ์
<xsl:import href="URI"/>
คุณลักษณะ
Attribute | Value | Description |
---|---|---|
href | URI | Required. Specifies the URI of the style sheet to import |
ตัวอย่าง 1
สมมติว่าคุณมีสไตล์ชีตชื่อ "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>
สไตล์ชีตที่สองชื่อ "cdcatalog_import.xsl" นำเข้า "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>
❮ ทำการอ้างอิงองค์ประกอบ XSLT ให้สมบูรณ์