[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

generate-id for copy

Subject: generate-id for copy
From: Andrew Wason <aw@xxxxxxxxxxx>
Date: Mon, 17 Jan 2000 15:28:19 -0500
andrew wason
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:



<?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/>

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


Thanks, Andrew -- Andrew Wason softcom aw@xxxxxxxxxxx


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.