Link to home
Create AccountLog in
Avatar of Pradeep0308
Pradeep0308Flag for India

asked on

Question Regarding XSLT

Hi,

I need to write an XSLT to convert the below:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<abc:ReceiveInvoice xmlns:abc='www.abc.com'>
  <abc:invoiceXML>
    <DOC_INFO>
      <DOC_TYPE>INVOICE</DOC_TYPE>
      <APP_DATE>09.10.2012</APP_DATE>
      <SUPPLIER_CODE>ABCDE</SUPPLIER_CODE>
      <GUID_KEY>12345678</GUID_KEY>
   </DOC_INFO>
      </abc:invoiceXML>
</abc:ReceiveInvoice>

TO

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<abc:ReceiveInvoice xmlns:abc='www.abc.com'>
      <abc:invoiceXML>&lt;DOC_INFO&gt;
  &lt;DOC_TYPE&gt;INVOICE&lt;/DOC_TYPE&gt;
  &lt;APP_DATE&gt;09.10.2012&lt;/APP_DATE&gt;
  &lt;SUPPLIER_CODE&gt;205124&lt;/SUPPLIER_CODE&gt;
  &lt;GUID_KEY&gt;07D750F7-0651-4631-AFEA-B474FC117B0F&lt;/GUID_KEY&gt;&lt;/DOC_INFO&gt;
      </abc:invoiceXML>
</abc:ReceiveInvoice>


Kindly asssit.

Regards
Pradeep
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Pradeep0308

ASKER

Hi,

It is creating the DOC_INFO group as XML elements and the child elements as well. I would like to have it as part of data for the invoiceXML element.

I tried to run this in XMLSpy.

Regards
Pradeep
THis is what comes out of it

<?xml version="1.0" encoding="UTF-8"?><abc:ReceiveInvoice xmlns:abc="www.abc.com">
    <abc:invoiceXML>
        &lt;DOC_INFO&gt;
            &lt;DOC_TYPE&gt;INVOICE&lt;/DOC_TYPE&gt;
            &lt;APP_DATE&gt;09.10.2012&lt;/APP_DATE&gt;
            &lt;SUPPLIER_CODE&gt;ABCDE&lt;/SUPPLIER_CODE&gt;
            &lt;GUID_KEY&gt;12345678&lt;/GUID_KEY&gt;
        &lt;/DOC_INFO&gt;
    </abc:invoiceXML>
</abc:ReceiveInvoice>

Open in new window


Tested with Oxygen Saxon, Xalan command line and msxml
Make sure that you look at the raw output, not at the browser view
also make sure that the trigger element is exactly the same
    <xsl:template match="abc:invoiceXML">
and the namespace declaration is the same in the XSLT and the XML
if you try my stylesheet on a different XML, it might fail for various reasons