[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] generate-id for copy
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|