XSLT <xsl:impor>
Referensi Elemen XSLT Lengkap
Definisi dan Penggunaan
Elemen <xsl:import> adalah elemen tingkat atas yang digunakan untuk mengimpor konten dari satu lembar gaya ke lembar gaya lainnya.
Catatan: Style sheet yang diimpor memiliki prioritas yang lebih rendah daripada style sheet yang diimpor.
Catatan: Elemen ini harus muncul sebagai simpul anak pertama dari <xsl:stylesheet> atau <xsl:transform>.
Sintaksis
<xsl:import href="URI"/>
Atribut
Attribute | Value | Description |
---|---|---|
href | URI | Required. Specifies the URI of the style sheet to import |
Contoh 1
Misalkan Anda memiliki lembar gaya yang disebut "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>
Lembar gaya kedua yang disebut "cdcatalog_import.xsl" mengimpor "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>
Referensi Elemen XSLT Lengkap