Skip to Content
avatar image
Former Member

CDATA in xml file

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Aug 02, 2007 at 09:49 AM

    hi,

    you can do it in mapping

    just add CDATA tags with UDF for example

    Regards,

    michal

    Add comment
    10|10000 characters needed characters exceeded

    • 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.

  • avatar image
    Former Member
    Aug 02, 2007 at 09:49 AM

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

    well you can always find and replace '<' & '>' with '&lt' and '&gt'

    Ranjit

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 07, 2007 at 12:58 PM

    thanks

    Add comment
    10|10000 characters needed characters exceeded