[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] understanding generate-id and node-equality [XSLT 1.0, Saxon 6.5.5]


Subject: Re: [xsl] understanding generate-id and node-equality [XSLT 1.0, Saxon 6.5.5]
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Aug 2008 11:40:16 -0400

At 2008-08-14 17:19 +0200, christoph.naber@xxxxxxxxxxx wrote:
using XSLT 1.0 and Saxon 6.5.5 I'm wondering whats the actual difference
between

<xsl:key name="child-key" match="child" use="parent::*"/>

<xsl:template match="parent" >
        <xsl:variable name="childs" select="key('child-key', parent::*)"/>
        ...
</xsl:template>

and

<xsl:key name="child-key" match="child" use="generate-id(parent::*)" />

<xsl:template match="parent" >
        <xsl:variable name="childs" select="key('child-key',
generate-id(parent::*))" />
        ...
</xsl:template>

I think I know what generate-id does,

The XSLT processor guarantees that all nodes of all source trees of a given transformation process have unique generated identifiers. Every time (in one process) you ask for the generated identifier for a node you get the same value, which will be different than the value returned for any other node.


No guarantee is made between two executions of the same stylesheet for the same source tree, only within either one of those executions.

but what is tested when I use the
former expression?

You are testing the string value of the concatenation in document order of all descendent text nodes of the parent of the node being added to the key table.


I hope this helps.

. . . . . . . . . Ken

--
Upcoming XSLT/XSL-FO hands-on courses:      Wellington, NZ 2009-01
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


Current Thread
Keywords