Get value out of generate-id() with value-of : generate id « XSLT stylesheet « XML






Get value out of generate-id() with value-of


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">
    <xsl:element name="line">
      <xsl:attribute name="status">done</xsl:attribute>
      <xsl:attribute name="hue">
                <xsl:value-of select="@color" />
            </xsl:attribute>
      <xsl:attribute name="number">
                <xsl:value-of select="amount" />
            </xsl:attribute>
      <xsl:attribute name="sourceElement">
                <xsl:text>src</xsl:text>
                <xsl:value-of select="generate-id()" />
            </xsl:attribute>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>

Output:

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

 








Related examples in the same category

1.generate-id() function
2.Create id with generate-id()