cancel
Showing results for 
Search instead for 
Did you mean: 

Pass XML file to String element

Former Member
0 Kudos

Hi Everybody,

Could someone tell me how to map whole xml to a single string element on the target side?

For example:

<?xml version="1.0" encoding="UTF-8" ?>

- <empr code="6017770" xmlns="http://localhost:7053/Mindef/MIWNSPay/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost:7053/Mindef/MIWNSPay/xsd http://localhost:7053/Mindef/MIWNSPay/xsd/empr.xsd">;

</empr code>

should be

<batch>

lt;?xml version="1.0" encoding="UTF-8" ?gt;

lt;empr code="6017770" xmlns="http://localhost:7053/Mindef/MIWNSPay/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost:7053/Mindef/MIWNSPay/xsd http://localhost:7053/Mindef/MIWNSPay/xsd/empr.xsd"gt;

lt;/empr codegt;

</batch>

Where '<' becomes lt; and '>' becomes gt;

The other acceptable format is:

<batch>

<!CDATA[[<?xml version="1.0" encoding=.....]]>

</batch>

Pls advice...

Regards,

Ashish

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member206604
Active Contributor
0 Kudos

Hi,

As Michal said you can use XSLT mapping

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<Target>
<Batch>
 <xsl:copy-of select="." />
</Batch>
</Target>
</xsl:template>
</xsl:stylesheet>

Thanks,

Prakash

MichalKrawczyk
Active Contributor
0 Kudos

hi,

you can do it with XSLT mapping:

have a look at my weblog:

/people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping

in my weblog I show how to do it with CDATA

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

bhavesh_kantilal
Active Contributor
0 Kudos

Ashish,

Would be very simple using Java Mapping. Convert the input stream to a String and then map it to the target field.


// <b>in</b> is the input to the excute(InputStream in , OutputStream out ) of java mapping
 
BufferedReader inp = new BufferedReader(new InputStreamReader(in));
StringBuffer buffer = new StringBuffer();
String line="";
while ((line = inp.readLine()) != null) {
buffer.append(line);
}

//source will now contain entire source XML as a string
String  source=buffer.toString();

Regards,

Bhavesh