<: Importación XSL> elemento XSLT
Definición y Uso
<Xsl: import> elemento es el elemento superior de los contenidos de una hoja de estilo en otra hoja de estilo.
Nota: La prioridad de las hojas de estilo importadas por debajo de estilo para exportar.
Nota: Este elemento debe ser <xsl: stylesheet> o <xsl: transform> es el primer nodo hijo.
gramática
<xsl:import href="URI"/>
propiedad
属性 | 值 | 描述 |
---|---|---|
href | URI | 必需。规定要导入的样式表的 URI。 |
Ejemplo 1
Suponga que tiene una hoja de estilo llamado "cdcatalog_ex3.xsl" de:
<?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 segunda llamada hoja de estilo, "cdcatalog_import.xsl" importará "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>
Ver el archivo XML , ver el archivo XSL , ver los resultados .
Nota: Este ejemplo no se puede ejecutar en Netscape 6, Netscape 6 no se admite porque el <xsl: apply-importaciones> elemento!
Completo manual de referencia del elemento XSLT