XSLT generate-id() function
May 28, 2021
XSL T
Table of contents
XSLT
generate-id()
function
This section explains the use of the generate-id() function in XSLT, including its syntax and parameters.
The complete XSLT function reference object
Definitions and usages
The generate-id() function returns a string value that uniquely identifies the specified node.
If the specified node set is empty, an empty string is returned.
If the node-set parameter is omitted, the default setting is the current node.
Grammar
string generate-id(node-set?)
Parameters
parameter
|
describe
|
node-set
|
Optional.The node set to generate a unique ID must be generated.
|
Instance 1
<?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>
<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 name="{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>
The complete XSLT function reference object