This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Kubernetes in Action and have Marko Luksa on-line!
See this thread for details.
Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

XSLT/XPath - Find unique text node value  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to retrieve all distinct values?
I think this is possible using axes
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a much simpler solution:
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the Key mechanism it will be more simpler.

Thanks
-Mahesh
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!