generate-id() function : generate id « XSLT stylesheet « XML






generate-id() function


File: Data.xml

<verse color="red">
  <amount>5</amount>
</verse>
File: Transform.xslt

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="xml" omit-xml-declaration="yes" indent="no" />
  
  <xsl:template match="verse">
    <line status="done" hue="{@color}" number="{amount}"
      sourceElement="src{generate-id()}" />
  </xsl:template>

  
</xsl:stylesheet>

Output:

<line status="done" hue="red" number="5" sourceElement="srcd2e1"/>

 








Related examples in the same category

1.Get value out of generate-id() with value-of
2.Create id with generate-id()