XSLT <xsl: import> elemento
Definizione e utilizzo
<Xsl: import> elemento è l'elemento superiore per i contenuti di un foglio di stile in un altro foglio di stile.
Nota: La priorità dei fogli di stile importati inferiori foglio di stile di esportazione.
Nota: Questo elemento deve essere <xsl: stylesheet> o <xsl: transform> è il primo nodo figlio.
grammatica
<xsl:import href="URI"/>
proprietà
属性 | 值 | 描述 |
---|---|---|
href | URI | 必需。规定要导入的样式表的 URI。 |
esempio 1
Supponiamo di avere un foglio di stile denominato "cdcatalog_ex3.xsl" di:
<?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>
La seconda chiamata foglio di stile, "cdcatalog_import.xsl" importerà "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>
Visualizzare il file XML , vedere il file XSL , visualizzare i risultati .
Nota: Questo esempio non può essere eseguito in Netscape 6, Netscape 6 non è supportato perché il <xsl: apply-import> elemento!
Manuale Completo XSLT elemento di riferimento