1

I am facing a wired problem, when ever I am trying to remove CDATA from my request. It works fine in my local IDE, but not in DataPower. The requirement is it should remove the CDATA tag if it finds one in the XML or else it should not do anything. Input XML:

<response status="200">
    <CustomELearningVO>
        <ClassListVO>
            <![CDATA[
<CLASS_TAB_OBJ>
<CLASS_TAB>
<CLASS_OBJ>
<ClassId>123456</ClassId>
<ClassName>Sample Class1</ClassName>
<Status>Not Attempted</Status>
<Link>link</Link>
<PlayEnable>Y</PlayEnable>
</CLASS_OBJ>

<CLASS_OBJ>
<ClassId>56789</ClassId>
<ClassName>Sample Class2</ClassName>
<Status>Failed</Status>
<Link>link2</Link><PlayEnable>Y</PlayEnable>
</CLASS_OBJ>

<CLASS_OBJ>
<ClassId>56788</ClassId>
<ClassName>Sample Class3</ClassName>
<Status>Failed</Status>
<PlayEnable>N</PlayEnable>
<PlayMessage>"Course cannot be played as Certfication subscribed to Course has Expired"</PlayMessage>
</CLASS_OBJ>

</CLASS_TAB>
</CLASS_TAB_OBJ>
]]>

        </ClassListVO>
        <eBSErrorCode>0</eBSErrorCode>
        <eBSErrorMessage>SUCCESS</eBSErrorMessage>
    </CustomELearningVO>
</response>

XSL I am using to remove CDATA:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"  />

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>


<xsl:template match="text()">

    <xsl:value-of select="." disable-output-escaping="yes" />
</xsl:template>

</xsl:stylesheet>
Sammy
  • 121
  • 4
  • 12
  • have you tried any alternative stylesheets ? Do they work ? may be one of the options here https://stackoverflow.com/questions/3708055/extract-cdata-using-xslt ? – Ramachandran.A.G Jul 29 '16 at 11:13
  • I have tried this as well, but no luck so far :( – Sammy Jul 29 '16 at 11:16
  • it's quite possible that your processor does not support `disable-output-escaping` - it is not required to do so by the XSLT specification. – michael.hor257k Jul 29 '16 at 12:52
  • But if I remove disable-output-escaping the < & > changes to < > – Sammy Jul 29 '16 at 14:04
  • Well, then it does support `disable-output-escaping` (or at least does not ignore it). So what exactly is the problem? Does it retain the CDATA markup? – michael.hor257k Jul 29 '16 at 14:18
  • Ohh no, if I remove the disable-output-escaping it doesn't do anything in DataPower. Its keeps the input as is. Is there any other way to remove the CDATA? – Sammy Jul 29 '16 at 14:51

1 Answers1

1

The issue was resolved using a stylesheet which works on serialized data of XML.

Sammy
  • 121
  • 4
  • 12