Função XSLT gerar-id()
❮ Referência da Função XSLTDefinição e uso
A função generate-id() retorna um valor de string que identifica exclusivamente um nó especificado.
Se o conjunto de nós especificado estiver vazio, uma string vazia será retornada. Se você omitir o parâmetro node-set, o padrão será o nó atual.
Sintaxe
string generate-id(node-set?)
Parâmetros
Parameter | Description |
---|---|
node-set | Optional. Specifies on which node-set to generate a unique id |
Exemplo 1
<?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>
<h3>Artists:</h3>
<ul>
<xsl:for-each select="catalog/cd">
<li>
<a href="#{generate-id(artist)}">
<xsl:value-of select="artist" /></a>
</li>
</xsl:for-each>
</ul>
<hr />
<xsl:for-each select="catalog/cd">
Artist: <a id="{generate-id(artist)}">
<xsl:value-of select="artist" /></a>
<br />
Title: <xsl:value-of select="title" />
<br />
Price: <xsl:value-of select="price" />
<hr />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Visualize o arquivo XML , Visualize o arquivo XSL e Visualize o resultado .
❮ Referência da Função XSLT