Transform xml with data from different sources to another xml using java

120 Views Asked by At

I have an xml file in which some elements contain certain values.For example:

<item>
     <origin>
          <![CDATA[KWI]]>
     </origin> 
     <destination>
          <![CDATA[DOH]]>
     </destination>
</item>

I have an excel sheet containing the country codes and port code mapping as:

COUNTRY_CODE PORT_CODE MANAGING_PORT_STATION
KW           KWI       MPS1
QA           DOH       MPS2

In the output xml, i need to put it something like:

<itemOut>
        <country><![CDATA[KW]]></country>
        <managingPortStation>MPS1</managingPortStation>
        <dest><![CDATA[DOH]]></dest>
</itemOut>

So in short, I need to combine some non xml sources into the output xml file based on the input xml file, along with the xml file. To accomplish the above, what should I use? Is it possible via xslt? Or what API's are available with java. I have just skimmed through the jaxp. But is it worth spending more time for my case? I would prefer to do it with java,rather than xslt since I am more familiar with it.

0

There are 0 best solutions below