XSLT <xsl:importar>
❮ Referência Completa do Elemento XSLT
Definição e uso
O elemento <xsl:import> é um elemento de nível superior usado para importar o conteúdo de uma folha de estilo para outra.
Nota: Uma folha de estilo importada tem precedência menor do que a folha de estilo importada.
Nota: Este elemento deve aparecer como o primeiro nó filho de <xsl:stylesheet> ou <xsl:transform>.
Sintaxe
<xsl:import href="URI"/>
Atributos
Attribute | Value | Description |
---|---|---|
href | URI | Required. Specifies the URI of the style sheet to import |
Exemplo 1
Suponha que você tenha uma folha de estilo chamada "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>
Uma segunda folha de estilo chamada "cdcatalog_import.xsl" importa "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>
❮ Referência Completa do Elemento XSLT