[Home] [By Thread] [By Date] [Recent Entries]
I want to copy a node in my source multiple times and assign each copy a
unique id attribute. generate-id is generating an ID for the context node
which is the same for each copy. Is there some way have generate-id
operate on the newly copied node to get a unique ID for each copy?
Here is my input document: <root> <node attr="myattr"/> </root> Here is my stylesheet:
<xsl:template match="node"> <xsl:apply-templates select="." mode="duplicate-node"/> <xsl:apply-templates select="." mode="duplicate-node"/> <xsl:apply-templates select="." mode="duplicate-node"/> <xsl:apply-templates select="." mode="duplicate-node"/> </xsl:template> <xsl:template match="*" mode="duplicate-node"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:attribute name="id"> <xsl:value-of select="generate-id()"/> </xsl:attribute> </xsl:copy> </xsl:template> </xsl:stylesheet> Here is the output: <node attr="myattr" id="doc2ab9"></node> <node attr="myattr" id="doc2ab9"></node> <node attr="myattr" id="doc2ab9"></node> <node attr="myattr" id="doc2ab9"></node>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|

Cart



