XSLT <xsl:import>Elemento
Manual de referencia completo de elementos XSLT
Definición y uso
El elemento <xsl:import> es un elemento de nivel superior que se utiliza para importar el contenido de una hoja de estilo en otra.
Nota:La prioridad de la hoja de estilo importada es menor que la de la hoja de estilo que la importa.
Nota:Este elemento debe ser el primer nodo hijo de <xsl:stylesheet> o <xsl:transform>.
Sintaxis
<xsl:import href="URI.html"/>
Atributos
| Atributo | Valor | Descripción |
|---|---|---|
| href | URI | Obligatorio. Especifica el URI de la hoja de estilo que se va a importar. |
Ejemplo 1
Supongamos que tiene una hoja de estilo llamada "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: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>
Una segunda hoja de estilo llamada "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.html"/>
<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.html"/>
<xsl:template match="/">
<xsl:apply-imports/>
</xsl:template>
</xsl:stylesheet>
、 、 。
Nota:¡Este ejemplo no se puede ejecutar en Netscape 6 porque Netscape 6 no admite el elemento <xsl:apply-imports>!
Manual de referencia completo de elementos XSLT Otras extensiones