0

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.

rahulserver
  • 10,411
  • 24
  • 90
  • 164
  • Yes, it's possible via XSLT using version 2.0. You can read a file with delimiters as a sequence of sequences, using the `unparsed-text()` function, along with the `tokenize()` function. – Bob Dalgleish Dec 25 '13 at 11:47
  • 1
    Which version of Excel? If the file is .xlsx, then it *is* XML - or more precisely, it's a zipped archive of several XML files, one of which holds the data. – michael.hor257k Dec 25 '13 at 17:14
  • @user3016153 its xlsx. Even if it may be xml, my main question is how to transform. – rahulserver Dec 26 '13 at 05:17

0 Answers0