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"/>