• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

xml transformation

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Using DOM or XSLT ??
 
srinivasan ganesan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!