XSLT <xsl: import> Element
Definicja i Wykorzystanie
<Xsl: import> Element jest najwyższym elementem zawartości arkusza stylów do innego arkusza stylów.
Uwaga: Priorytetem importowanych arkuszy stylów niższych niż stylów eksportu.
Uwaga: Ten element musi być <xsl: stylesheet> lub <xsl: transform> to pierwszy węzeł dziecko.
gramatyka
<xsl:import href="URI"/>
nieruchomość
属性 | 值 | 描述 |
---|---|---|
href | URI | 必需。规定要导入的样式表的 URI。 |
Przykład 1
Załóżmy, że masz arkusz stylów o nazwie "cdcatalog_ex3.xsl" stanowi:
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>
<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, zwany "cdcatalog_import.xsl" stylesheet zaimportuje "cdcatalog_ex3.xsl":
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>
<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>
Zobacz plik XML , zobaczyć, jak plik XSL , przeglądać wyniki .
Uwaga: Ten przykład nie można uruchomić w Netscape 6, Netscape 6 nie jest obsługiwana, ponieważ <xsl: apply-import> Element!
Kompletna instrukcja XSLT element odniesienia