[xsl] key(), generate-id question

Subject: [xsl] key(), generate-id question
From: "Endre Magyari" <endre@xxxxxxxxx>
Date: Sun, 10 Nov 2002 19:04:51 +0200
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