• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xml transformation

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if anyone has done this before but I'd appreciate any suggestions from you.
I have two xml documents. I want to transform the second document using the first document as input. as an ex.
XML1.xml
<ROW num="1">
<EMPNO>7839</EMPNO>
</ROW>

XML2.xml
<ROWSET>
<ROW num="1">
<EMPNO>4235</EMPNO>
<ENAME>BLACK</ENAME>
</ROW>
<ROW num="2">
<EMPNO>4234</EMPNO>
<ENAME>SPARK</ENAME>
</ROW>
</ROWSET>
The transformed document will be
<ROWSET>
<ROW num="1">
<EMPNO>7839</EMPNO>--the value here is from the 1st document
<ENAME>KING</ENAME>
</ROW>
<ROW num="2">
<EMPNO>7788</EMPNO>
<ENAME>SCOTT</ENAME>
</ROW>
</ROWSET>
The first document (input) can contain many elements. I want to search for the occurences of all of them and create the resulting document with the new values.
If you have any questions, let me know.
Thanks in advance,
Srinivas
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using DOM or XSLT ??
 
srinivasan ganesan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to implement it using DOM as I speak but there's one little problem I ran into. I want to be able to comment out the portion of second document or not include the set of elements that are commented out in the input
Ex:
XML1.xml
<Element1>
<Child1>
<!--commentedNode1>
<commentedChild1 attr1="value1" attr2="value2">
</commentedNode1>
<CommentedNode2>
<commentedChild2 attr1="value1" attr2="value2">
</CommentedNode2 -->
<UncommentedNode attr1="value1" attr2="valu2 />
</Child1>
</Element1>
XML2.xml
<Element1>
<Child1>
<commentedNode1>
<commentedChild1 attr1="value1" attr2="value2">
</commentedNode1>
<CommentedNode2>
<commentedChild2 attr1="value1" attr2="value2">
</CommentedNode2>
<UncommentedNode attr1="value1" attr2="valu2 />
</Child1>
</Element1>

The output should look like this
XML3.xml
<Element1>
<Child1>
<UncommentedNode attr1="value1" attr2="valu2 />
</Child1>
</Element1>
Do you think I can achieve this using DOM API or should I have write a workaround. I'm not sure how to implement this at this point.
Thanks,
Srinivas
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic