how to return only distinct values from xpath expression

Hi Experts,

This might be a quick one but I am struggling to figure out how to do it.
I have the following xpath expression:
doc("E://xml.xml") /*/diving[./sites[3] and vessel="Compass"]/date

This xpath returns the dates where more than 3 sites have been operated on by the Compass vessel.
<?xml version="1.0" encoding="UTF-8"?>

As you can see, the 27-09-2015 appears three times!
How can I rewrite my xpath expression for it to return only distinct values (i.e. no repeats)

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gertone (Geert Bormans)Information ArchitectCommented:
Hi, you could write an XPath expression that does this for you.
But I saw on one of your earlier questions that you were using the XPath in the context of an XSLT
XSLT has some extra functionality that makes this request easier such as key()
Can you confirm that essentialy you need this inside an XSLT?
Gertone (Geert Bormans)Information ArchitectCommented:
oh, and a demo xml would help
Gertone (Geert Bormans)Information ArchitectCommented:
diving[./sites[3] and vessel="Compass"][not(date = preceding-sibling::diving[./sites[3] and vessel="Compass"]/date)]/date

could work, provided the structure of your source XML

if not

diving[./sites[3] and vessel="Compass"][not(date = preceding::diving[./sites[3] and vessel="Compass"]/date)]/date

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

SmanyxAuthor Commented:
Both expressions yield the expected result.

P.S. Could you recommend some very well written documentation on xpath, xslt and xquery? I know there heaps of stuff on the Internet but what I want is something that takes you into the learning journey quite comprehensively and with a lot of examples, practical exercises...
Gertone (Geert Bormans)Information ArchitectCommented:
For me by far the best learning resource for XSLT and XPath is Doug Tidwells book
2nd edition is more complete and does XSLT2
if you are only into XSLT1, the first edition is a splendid journey and easy read.

I use that book for XSLT trainings for a while now, and I could not have a better background resource for my students. I think it fits your requirement well.
There are ebooks from it and you can find them online for free (so you can evaluate, please buy if you are happy)

Once you get the grips
is a must have reference book on your desk

Patricia Walmsleys book on XQuery is a good resource (after you get the grip on Xpath)
I only have the first edition, I think it is worth buying the second that got update for XQuery 3.1
SmanyxAuthor Commented:
Thank you so much !!
Gertone (Geert Bormans)Information ArchitectCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.