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

Re: [xsl] Find distinct nodes from a sequence


Subject: Re: [xsl] Find distinct nodes from a sequence
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Thu, 07 Jul 2011 10:11:33 +0200

a) upgrade to a more recent version of Saxon

b) Something like
<xsl:for-each-group select="person" group-by="@name">
<xsl:sequence select="." />
</xsl:for-each-group>
should do the trick. You could also group-by="generate-id(.)" if the nodes are really identical.
<xsl:sequence select="." /> selects the context item of each group which is, per spec, the first item in the group.


Gerrit


On 2011-07-07 10:05, Pushkar Khadilkar wrote:
Hi List,

I have a function getNodes() that returns a sequence of nodes(>= 1) from source tree by xsl:sequence statement.

I want to remove duplicate nodes from this sequence.

The duplicate nodes in the sequence are not different nodes from source tree with same values for some attributes but actually refer to same node in source tree.

For example , Consider following tree

<person name=a/>
<person name=b/>

The function getNodes() might return a sequence containing 2 nodes both of which refer to same node (<person name=a/>) of the source tree.

I cannot use some logic like select node whose generate-id(.) is not equal to generate-id(preceding-node) as the duplicate nodes actually refer to same node of source tree and hence preceding wont work.

Im using Saxon HE 8.8 Java.

Is there a function for selecting unique nodes from a sequence ?

There was a saxon:distinct function in older versions of saxon but is not present in Saxon 8.

Any help in this regard is highly appreciated.

Thanks ,
Pushkar Khadilkar

DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.


-- Gerrit Imsieke Geschdftsf|hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vvckler


Current Thread