cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CDATA in xml file

Former Member
0 Likes
2,728

Hi everybody

Can anyone tell me the best way to transform parts of my xml file as CDATA ?

For some part of my xml file i need the '&lt' '&gt' instead of < and > .

Thanks for your help

View Entire Topic
MichalKrawczyk
Active Contributor
0 Likes

hi,

you can do it in mapping

just add CDATA tags with UDF for example

Regards,

michal

Former Member
0 Likes

Hi michal

Thats sounds like a clever and simple solution, exactly what should my UDF do to my xml fields? It would be great if u can shown with a simple example.

thankls a lot

MichalKrawczyk
Active Contributor
0 Likes

hi,

you can even use concat function from XI standard functions

add [!CDATA.. at the begining

and .] at the end of your string

BTW

you need to try [!CDATA.. or [[!CDATA.. or [[[!CDATA.. but one of them will work

for sure as I did that a few times in message mappings

Regards,

michal

Former Member
0 Likes

Hi michal

I tried using [[!CDATA in different formats as you suggested but none is producing the desired result. Can you identify which format you have exactly used and let me know please?

This is my xml file

<ns0:QueryString_Initial_MT xmlns:ns0="urn:ABG.com/EDI/PurchaseOrders">

<pin/>

<user_id/>

<pwd/>

<orders_lines>

<isbn>sfdg</isbn>

<record_dues>fgfh</record_dues>

<part_supply>fdg</part_supply>

<order_quantity>fdds</order_quantity>

<order_line_reference>ffg</order_line_reference>

<special_instructions>f</special_instructions>

<affiliate_id>dfg</affiliate_id>

<promotional_code>df</promotional_code>

</orders_lines>

<orders_ref>f</orders_ref>

</ns0:QueryString_Initial_MT>

I want the <orders_line> tag and its sub tags to be presented as a string.

Even an XSLT for it be a great help.

thanks a lot

Former Member
0 Likes

Hi michal

By adding the <![CDATA[ tags i am able to see that everything in between these tags will be trated as a string, but how can i put an entire node with subnodes into these tags using the concat function?

Thank you

Sudheer

henrique_pinto
Active Contributor
0 Likes

Sudheer,

as per your requirement, the following XSLT would help:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="urn:ABG.com/EDI/PurchaseOrders">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="orders_lines">
		<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[
		
			
		
		]]
		>
	
]]>

However, it is strange not to have a wrapping tag around the string.

If you wanted only the subtags of <orders_lines> to be inserted in the string, just exchange the <xsl:copy> and <CDATA> tags.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="urn:ABG.com/EDI/PurchaseOrders">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="orders_lines">
		<xsl:copy>
			<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[
			
			]]
			>
		
	
]]>

Regards,

Henrique.