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
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
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
XML and Related Technologies
Removing nodes based on a element
Raj Murthy
Greenhorn
Posts: 14
posted 19 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: 28417
102
I like...
posted 19 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 19 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
Consider Paul's
rocket mass heater
.
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...