Re: [xsl] weird key-nodeset behavior

Subject: Re: [xsl] weird key-nodeset behavior
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 25 Nov 2004 16:03:38 GMT
> 3) the key definition does not work for the nodeset.

They key indexes all elements in the document: it has nothing to so with
any variable.

If you have 
<xsl:key name="key" match="dovizler" use="key">

and <xsl:variable name="mydovizler" select="dovizler[2]"/>

Then given 
<x>
<dovizler><key>a</key></dovizler>
<dovizler><key>a</key></dovizler>
</x>

Your expression of

select="$mydovizler[generate-id(.) =  generate-id(key('dkey',key)[1])]"

will work, but it will select all the elements in $mydovizler that are
the first elements in the document for their key value.

In this case there is only one element in mydovizler, and it has key
value 'a' but it isn't the first such element in the document so
the empty node set is selected.

the key definition works, it just isn't doing what you want.

Unfortunately it isn't clear what you do want as you only showed the non
working definition, not a description of what you are trying to do.

> should i give the input file?(xml and xsl)

complete runnable files are good, but best to take the time to cut them
down as above to five or six lines, so that just the problem is
highlighted not your entire input source.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread