cancel
Showing results for 
Search instead for 
Did you mean: 

creation of CDATA with message mapping

Former Member
0 Kudos

Hello all,

Is everyone absolutely sure that a cdata string cannot be created in the middle of an xml file using message mapping?

I have tried doing the XSL map in other blogs I even tried writing a whole XSL map in xml spy - yet xi complains about not finding this class file and that class file. I'm having a hard time believing that this is so hard to do in XI - especially when Microsoft web service implementation seem to long for data crammed into a string ( in my experience ).

Any help is GREATLY appreciated.

Thank you!!!

Scott

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

Check if this weblog is of any help to you - /people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping

Former Member
0 Kudos

Yes I have been through that already. It's a very well written blog however when I perform the steps all I get on my output is an empty <name> tag with empty cdata in it.

Former Member
0 Kudos

Hi Scott,

Pls follow the following steps to insert XML string into a single element:

Create a xsl file with the following data:

<?xml version='1.0' ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <i><b>NSpace</b></i>>

<xsl:template match="/">

<namespace:name1>

<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text><xsl:copy-of select="<b>//namespace:name</b>"/><xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text><xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>

</namespace:name1>

</xsl:template>

</xsl:stylesheet>

In the above code I have removed xmlns:p2="http://frik.bcc.com.pl" which is not needed.

Also you have to put '<b>//</b>' before the target element from where you want to start creating XML string over here it is <b>name</b>. And <b>name1</b> is the element you want to store the XML string in.

So anything in the element <b>name</b> will be stored in <b>name1</b>

Regarding the <b>namespace:</b> To find out the namespace test your message mapping between the source and the target without adding XSLT mapping. After testing click on <b>'SCR'</b> tab present on top of the target window. There you will see <b>ns1: or ns2:</b> attached to each element. Replace <b>namespace</b> in the above code with <b>ns1: or ns2:</b>. And replace <b>NSpace</b> in the above XSL Header with the namespace in the SCR of test map.

So the final XSL file will look like that:

<?xml version='1.0' ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <i><b>xmlns:ns1="http://sap.com/xi/HR"</b></i>>

<xsl:template match="/">

<<b>ns1:</b>name1>

<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text><xsl:copy-of select="<b>//ns1:name</b>"/><xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text><xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>

</<b>ns1:</b>name1>

</xsl:template>

</xsl:stylesheet>

Dont forget to put '//' before the target element.

This should work. Or pls put the source and target xml struct and we will assist you further.

Regards,

Ashish

Former Member
0 Kudos

Thank you Ashish. However I am trying to put this cdata node in the middle of a regular xml file so .. .message mapping to xsl map then back to message map. I have been able to do it with straight message mapping but it is very hairy. Here is a sample output ..

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

<ns1:getSampleResponse xmlns:ns1="http://ABC/webservices/InventoryQuery/"><ns1:getSampleResponse>true</ns1:getSampleResponse><inventoryOutputString>&amp;lt;locationCode&amp;gt;LOCATIONCODETESTDATA&amp;lt;/locationCode&amp;gt;&amp;lt;inventoryStatusCode&amp;gt;INVENTORYCODETESTDATA&amp;lt;/inventoryStatusCode&amp;gt;&amp;lt;inventoryStatus&amp;gt;INVENTORYSTATUSTESTDATA&amp;lt;/inventoryStatus&amp;gt;&amp;lt;quantity&amp;gt;QUANTITYTESTDATA&amp;lt;/quantity&amp;gt;</inventoryOutputString><ns1:errorCode>ec</ns1:errorCode><ns1:errorDescription>des</ns1:errorDescription></ns1:getSampleResponse>

Answers (0)