Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

xsl processing question

 
randy singh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic