XSLT and XPath selecting distinct nodes

It is a complicated task to select distinct nodes or to use grouping useing xslt. There are no simple syntax to write this type XPath query.

The work arround is quite difficult to remember, thats why i decided to duplicate internet content in my blog.

Let’s say, that the XML source is:

[code lang=”xml”]










[/code]Lets say, that the task is to select distinct nodes grouping by attribute1.The Xpath will look like this:

[code lang=”xml”]
//MyData[not(@attribute1=preceding-sibling::[email protected])][email protected]
[/code]

3 thoughts on “XSLT and XPath selecting distinct nodes

  1. Madushan

    hi, this works fine without namespaces. can you please give a sample how to use this with a xml
    which has namespaces.

    thanks
    Madushan

  2. Eric Tamminga

    Thanks!

    Simplicity is the key to brilliance.

    You’re bookmarked in my Delicious.

    Regards, Eric

Leave a Reply