Subject: Re: [xsl] Assigning unique id to new node using generate-id() From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Wed, 13 Aug 2003 13:10:11 -0400 |
I'd like this stylesheet to copy all existing credential nodes and create a new
node assigning a unique id
with generate-id().
It appears as if the generate-id
call doesn't observe existing id's in the current/copied credential nodes. So I
end up with duplicate (illegal) id's. I've tried passing several context nodes
to the generate-id() function, but with no luck.
Sample XSL:
<xsl:template match="/profile">
<profile>
<xsl:for-each select="credential">
<xsl:copy-of select="."/>
</xsl:for-each>
<credential>
<xsl:attribute name="id">
<xsl:value-of select="generate-id()"/>
</xsl:attribute>
<username><xsl:value-of select="$username"/></username>
<password><xsl:value-of select="$password"/></password>
<description><xsl:value-of select="$description"/></description>
<lastModified><xsl:value-of
select="java:getCurrentDateTimeGMT($dateHelper)"/></lastModified>
</credential>
</profile>
</xsl:template>
My current workaround is to transform twice. The first transformation appends the new credential node. The second transformation assigns an id (using generate-id()) to any credential nodes without an id (probably only newly created). Seems like I should be able to do it all in one transform.
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Assigning unique id to ne, David Carlisle | Thread | RE: [xsl] Assigning unique id to ne, Michael Kay |
Re: [xsl] Assigning unique id to ne, David Carlisle | Date | [xsl] How to "copy" a DTD reference, Mark R. Diggory |
Month |