XSLT <xsl:import>
❮ Pełne odniesienie do elementu XSLT
Definicja i użycie
Element <xsl:import> jest elementem najwyższego poziomu, który służy do importowania zawartości jednego arkusza stylów do innego.
Uwaga: importowany arkusz stylów ma niższy priorytet niż importowany arkusz stylów.
Uwaga: ten element musi pojawić się jako pierwszy węzeł podrzędny <xsl:stylesheet> lub <xsl:transform>.
Składnia
<xsl:import href="URI"/>
Atrybuty
Attribute | Value | Description |
---|---|---|
href | URI | Required. Specifies the URI of the style sheet to import |
Przykład 1
Załóżmy, że masz arkusz stylów o nazwie „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>
Drugi arkusz stylów o nazwie „cdcatalog_import.xsl” importuje „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>
❮ Pełne odniesienie do elementu XSLT