This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes xsl processing question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xsl processing question" Watch "xsl processing question" New topic
Author

xsl processing question

randy singh
Greenhorn

Joined: Sep 24, 2003
Posts: 1
I have an input xml that looks like following :
<mydoc>
<myelem>
<val>23</val>
<name>george</name>
</myelem>
<myelem>
<val>55</val>
<name>tim</name>
</myelem>
<myelem>
<val>23</val>
<name>george</name>
</myelem>
<mydoc>
I need to do the following :
1. Go through each myelem
2. if there are more than one myelem
3. if the "val" of the current myelem is equal to another "myelem" val ( there can be many nodes randomly interdispersed )
4. then add the val, and collapse the "equal" myelem's into one myelem
5. if not print out myelem it out as is
For example in the above case it will be :
<mydoc>
<myelem>
<name>george</name>
<val>46</val>
</myelem>
<myelem>
<name>tim</name>
<val>55</val>
</myelem>
<mydoc>
any pointers how to do this ? I am using xalan processor.
thanks
randi
Tony Yan
Ranch Hand

Joined: Apr 10, 2002
Posts: 170
The best way is to set up a key valued on concat of name and val. Pick up the unique key (in your case, name+val) and output each one.

Muenchian method


Tony Yan<br /> <br />IBM Certified Developer XML and Related Technology<br />Sun Certified Web Component Developer For J2EE Platform<br />Sun Certified Programmer For Java 2 Platform
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: xsl processing question
 
It's not a secret anymore!