Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within XML
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830
this week in the
Programmer Certification
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
XML and Related Technologies
Removing nodes based on a element
Raj Murthy
Greenhorn
Posts: 14
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Need to remove duplicates in a xml file based on a element's value.
Just use the first node with the element in the resulting list;
Here is a sample xml:
<list> <book> <name>Title1</name> <author>Tom</author> </book> <book> <name>Title2</name> <author>Tom</author> </book> <book> <name>Title3</name> <author>Jim</author> </book> <book> <name>Title4</name> <author>Jim</author> </book> </list> -------------------------------------
The result needs to be:
Title1 Tom
Title3 Jim
In this case use the first occurance of the 'Author' element.
How can i accomplish this in xslt?
Any hints on which xsl functions i can use for this?
Thanks in Advance,
Rajiv
[ December 28, 2005: Message edited by: Rajiv Rangarajan ]
Paul Clapham
Sheriff
Posts: 28331
97
I like...
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Consider the answer to the identical question posted on the Sun forum.
Raj Murthy
Greenhorn
Posts: 14
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Paul,
Yes, I did find the solution for the xml I posted
I have listed the same below for anyone interested.
<xsl:variable name="unique-list" select="//book[not(author=following::book/author)]"/> <xsl:template match="list"> <html><body><table border="1"> <xsl:for-each select="$unique-list"> <tr><td> <xsl:value-of select="name" /> </td><td> <xsl:value-of select="author" /> </td></tr> </xsl:for-each> </table></body></html> </xsl:template> </xsl:stylesheet>
Cheers,
Rajiv
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Castor: How to map list items within a "parent" list element?
XML One liners for the exam....
Passing Set<java.lang.Object> and List<java.lang.Object> in Axis 2.0
Testing web application for jump from Tomact to Jboss on load
How to implement getElementById() with Xerces using XML Schema?
More...