• 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

Joining and extracting two xmls

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to xml. I need to combine the below sample two xmls and needs to produce the output also as a xml. How can i achieve this... I am using JDBC's Webrowset feature to get the input xmls from the DB.


<?xml version="1.0"?>
<webRowSet xmlns="http://java.sun.com/xml/ns/jdbc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/jdbc http://java.sun.com/xml/ns/jdbc/webrowset.xsd">

question.xml (input 1)

<data>
<currentRow>
<columnValue>2</columnValue>
<columnValue>Select all that apply to grim reaping.</columnValue>
</currentRow>
<currentRow>
<columnValue>3</columnValue>
<columnValue>How old was George when she died?</columnValue>
</currentRow>
</data>
</webRowSet>

option.xml (input xml 2)

<?xml version="1.0"?>
<webRowSet xmlns="http://java.sun.com/xml/ns/jdbc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/jdbc http://java.sun.com/xml/ns/jdbc/webrowset.xsd">
<data>
<currentRow>
<columnValue>2</columnValue>
<columnValue>Post-Its</columnValue>
</currentRow>
<currentRow>
<columnValue>2</columnValue>
<columnValue>Black robe</columnValue>
</currentRow>
<currentRow>
<columnValue>2</columnValue>
<columnValue>E.T.D.</columnValue>
</currentRow>
</data>
</webRowSet>


The result should be something like the below xml format... I mean I need to match the first "columnValue" element of both xml and if the match then I need I take second "columnValue" element from both xml and need to insert into a new set of xml elements in the output...

<?xml version="1.0" encoding="UTF-8"?>
<QuestionBank>
<Test>
<question>Select all that apply to grim reaping</question>
<option>Post-Its</option>
<option>Black robe</option>
<option>E.T.D</option>


</Test>
</QuestionBank>

[ December 19, 2006: Message edited by: karthik venkatesan ]
[ December 19, 2006: Message edited by: karthik venkatesan ]
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you get both those documents from the same database? If so, I would suggest going back and doing the join in the database. SQL is very good at joining tables, XML is not.

But if that isn't practical, I would suggest you use an XSLT transformation to do this. I won't go into the details at this point because you are new to XML, so they wouldn't mean anything yet.
 
My first bit of advice is that if you are going to be a mime, you shouldn't talk. Even the tiny ad is nodding:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic