File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Product and Other Certifications and the fly likes XSLT/XPath - Find unique text node value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "XSLT/XPath - Find unique text node value " Watch "XSLT/XPath - Find unique text node value " New topic
Author

XSLT/XPath - Find unique text node value

Raymond Law
Greenhorn

Joined: Oct 07, 2002
Posts: 12
I have the following XML and want to retreive unique text node. Can xPath/XSLT achieve that??
<root>
<Dept>IS</Dept>
<Dept>AD</Dept>
<Dept>IS</Dept>
<Dept>HR</Dept>
<Dept>RD</Dept>
<Dept>HR</Dept>
</root>
Result:
IS
AD
HR
RD


RL
Steven Broadbent
Ranch Hand

Joined: Dec 10, 2002
Posts: 400
You want to retrieve all distinct values?
I think this is possible using axes


"....bigmouth strikes again, and I've got no right to take my place with the human race...."<p>SCJP 1.4
Micheal Jacob
Ranch Hand

Joined: Nov 25, 2002
Posts: 89
Hi,
Here is the code. But in this i have faced one problem. The problem is,any axis looks on the original source document, not the logical xml document after ascending.
so this piece of code will fetch the unique values when it is in ascending order.


This xsl look upon the previous given xml.
Let's wait for others view on this.
Micheal
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Here is a much simpler solution:
Mahesh Chalil
Ranch Hand

Joined: Jan 24, 2002
Posts: 147
Using the Key mechanism it will be more simpler.

Thanks
-Mahesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XSLT/XPath - Find unique text node value