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

key(), generate-id question

Subject: key(), generate-id question
From: "Endre Magyari" <endre@xxxxxxxxx>
Date: Sun, 10 Nov 2002 19:04:51 +0200
xsl key generate id
Dear list,

    I have az XML file with elements that may contain an attribute named
_id. This element is defined as ID in the corresponding DTD. The XML file
may containt elements without this attribute.

    In the output tree, I need to generate xmi.id attribute for each
element, regardless of the existence of the _id attribute on the input side.

    On the input side I have  _id attributes with values like: id000001,
id000003, ... and so on.
    On the output side I need xmi.id attributes like: xmi.000001, xmi.000003

    This line is fine when I have _id attributes for all elements:

<xsl:attribute name="xmi.id"><xsl:choose><xsl:when
test="@_id">xmi.<xsl:value-of
select="substring-after(@_id,'id')"/></xsl:when><xsl:otherwise><xsl:value-of
select="generate-id()"/></xsl:otherwise></xsl:choose></xsl:attribute>


    The problem is that the generate-id() generates stg completely different
and I would like to generate an ID in the same form (xmi.number) with the
first/next available number. In order to achive this, I defined _id as a
key:

<xsl:key name="_id" match="node()" use="@_id"></xsl:key>


    But I have no idea how to make the function generate-id() to generate
the next available id from this key.

Any ideas? Maybe I'm heading in the wrong direction? Thank you,
Endre



 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.