Topic
  • 8 replies
  • Latest Post - ‏2013-03-06T14:43:42Z by SystemAdmin
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic disable-output-escaping CDATA problem

‏2012-11-12T11:40:26Z |
Hi

On WebSphere DataPower XI50 I have trouble using Edit/Submit on an xsl-file that contains:

<xsl:text disable-output-escaping="yes"><![CDATA&]></xsl:text>

The xml is being validated just fine.

The CDATA tag seems to cause an internal error when submitting the file with the line content above - even though an upload of the same file works.

It could be a bug in the firmware 5.0.0.1 but could I use this line instead:

&

Any suggestions?
Updated on 2013-03-06T14:43:42Z at 2013-03-06T14:43:42Z by SystemAdmin
  • Daviiid
    Daviiid
    289 Posts

    Re: disable-output-escaping CDATA problem

    ‏2012-11-12T13:31:30Z  
    Hello

    Try this : <xsl:text disable-output-escaping="yes"><![CDATA&]></xsl:text>
  • Daviiid
    Daviiid
    289 Posts

    Re: disable-output-escaping CDATA problem

    ‏2012-11-12T13:32:03Z  
    hello

    Try this :
    <xsl:text disable-output-escaping="yes"><![CDATA[&]]></xsl:text>
    
    Updated on 2014-03-25T02:45:55Z at 2014-03-25T02:45:55Z by iron-man
  • HermannSW
    HermannSW
    4749 Posts

    Re: disable-output-escaping CDATA problem

    ‏2012-11-12T18:17:02Z  
    • Daviiid
    • ‏2012-11-12T13:32:03Z
    hello

    Try this : <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><xsl:text disable-output-escaping="yes"><![CDATA[&]]></xsl:text> </pre>
    Hi Michael,

    David is right with his suggestion, in your first posting the 2nd closing square bracket seems to be missing.

    Here you can see David's solution in action -- you will see the unescaped '&' character, but without CDATA section:
    
    $ echo 
    "<foobar/>" | coproc2 cda.xsl - http:
    //dp5-l3:2223 ; echo & $ $ cat cda.xsl <xsl:stylesheet version=
    "1.0" xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" > <xsl:output omit-xml-declaration=
    "yes" /> <xsl:template match=
    "/"> <xsl:text disable-output-escaping=
    "yes"><![CDATA[&]]></xsl:text> </xsl:template> </xsl:stylesheet> $
    


    Trying to output any XML construct by <xsl:text disable-output-escaping="yes"> is ALWAYS a bad practice.

    Using <xsl:output>'s attribute "cdata-section-elements" is the correct way to generate CDATA sections in output:
    
    $ echo 
    "<foobar/>" | coproc2 cdb.xsl - http:
    //dp5-l3:2223 ; echo <out><![CDATA[&]]></out> $ $ cat cdb.xsl <xsl:stylesheet version=
    "1.0" xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" > <xsl:output omit-xml-declaration=
    "yes" cdata-section-elements=
    "out"/> <xsl:template match=
    "/"> <out>&amp;</out> </xsl:template> </xsl:stylesheet> $
    


     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: disable-output-escaping CDATA problem

    ‏2013-01-25T16:08:45Z  
    • HermannSW
    • ‏2012-11-12T18:17:02Z
    Hi Michael,

    David is right with his suggestion, in your first posting the 2nd closing square bracket seems to be missing.

    Here you can see David's solution in action -- you will see the unescaped '&' character, but without CDATA section:
    <pre class="jive-pre"> $ echo "<foobar/>" | coproc2 cda.xsl - http: //dp5-l3:2223 ; echo & $ $ cat cda.xsl <xsl:stylesheet version= "1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" > <xsl:output omit-xml-declaration= "yes" /> <xsl:template match= "/"> <xsl:text disable-output-escaping= "yes"><![CDATA[&]]></xsl:text> </xsl:template> </xsl:stylesheet> $ </pre>

    Trying to output any XML construct by <xsl:text disable-output-escaping="yes"> is ALWAYS a bad practice.

    Using <xsl:output>'s attribute "cdata-section-elements" is the correct way to generate CDATA sections in output:
    <pre class="jive-pre"> $ echo "<foobar/>" | coproc2 cdb.xsl - http: //dp5-l3:2223 ; echo <out><![CDATA[&]]></out> $ $ cat cdb.xsl <xsl:stylesheet version= "1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" > <xsl:output omit-xml-declaration= "yes" cdata-section-elements= "out"/> <xsl:template match= "/"> <out>&amp;</out> </xsl:template> </xsl:stylesheet> $ </pre>

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    Hermann,

    Client would send a soap meaage which has CDATA tied with xml. We need to grab the XML request once we get the xml response we need to embed this XML request with CDATA and send the response to client.

    This is not working out:-

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

    Can you please help us out.

    Thanks!
    Salla
    Updated on 2014-03-25T02:41:23Z at 2014-03-25T02:41:23Z by iron-man
  • HermannSW
    HermannSW
    4749 Posts

    Re: disable-output-escaping CDATA problem

    ‏2013-01-25T21:09:54Z  
    Hermann,

    Client would send a soap meaage which has CDATA tied with xml. We need to grab the XML request once we get the xml response we need to embed this XML request with CDATA and send the response to client.

    This is not working out:-

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><arg0> <xsl:text disable-output-escaping="yes"><</xsl:text> ![CDATA[ <xsl:copy-of select="." /> ]] <xsl:text disable-output-escaping="yes">></xsl:text> </arg0> </pre>
    Can you please help us out.

    Thanks!
    Salla
    > This is not working out:-
    >
    >
    
    >                                  <arg0> >                                               <xsl:text disable-output-escaping=
    "yes"><</xsl:text> >                                             ![CDATA[ >                                           <xsl:copy-of select=
    "." /> > ]] >                                                <xsl:text disable-output-escaping=
    "yes">></xsl:text> >                                     </arg0> >
    

    >
    Of course, as I said above using <xsl:text disable-output-escaping="yes"> to do such things is bad practice.

    Please use this:
    
    <xsl:stylesheet version=
    "1.0" xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" > <xsl:output omit-xml-declaration=
    "yes" cdata-section-elements=
    "arg0"/> <xsl:template match=
    "/"> <arg0> <dp:serialize select=
    "."/> </arg0> </xsl:template> </xsl:stylesheet>
    


    The <dp:serialize> serializes your XML to a string.
    And it will be sent inside CDATA section because of cdata-section-element.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • PullMeOut
    PullMeOut
    47 Posts

    Re: disable-output-escaping CDATA problem

    ‏2013-01-26T00:52:28Z  
    Hermann,

    Client would send a soap meaage which has CDATA tied with xml. We need to grab the XML request once we get the xml response we need to embed this XML request with CDATA and send the response to client.

    This is not working out:-

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><arg0> <xsl:text disable-output-escaping="yes"><</xsl:text> ![CDATA[ <xsl:copy-of select="." /> ]] <xsl:text disable-output-escaping="yes">></xsl:text> </arg0> </pre>
    Can you please help us out.

    Thanks!
    Salla
    try this

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <xsl:output method="xml" encoding="UTF-8" indent="yes" cdata-section-elements="xmldata"/>
    <xsl:template match="/">
    <xsl:variable name="xyz" select="."/>
    <soap:Envelope>
    <soap:Body>

    <xmldata>
    <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
    <xsl:copy-of select="$xyz"/>
    <xsl:text disable-output-escaping="yes">]]></xsl:text>
    </xmldata>

    </soap:Body>
    </soap:Envelope>
    </xsl:template>
    </xsl:stylesheet>
  • HermannSW
    HermannSW
    4749 Posts

    Re: disable-output-escaping CDATA problem

    ‏2013-01-26T17:42:19Z  
    • PullMeOut
    • ‏2013-01-26T00:52:28Z
    try this

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <xsl:output method="xml" encoding="UTF-8" indent="yes" cdata-section-elements="xmldata"/>
    <xsl:template match="/">
    <xsl:variable name="xyz" select="."/>
    <soap:Envelope>
    <soap:Body>

    <xmldata>
    <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
    <xsl:copy-of select="$xyz"/>
    <xsl:text disable-output-escaping="yes">]]></xsl:text>
    </xmldata>

    </soap:Body>
    </soap:Envelope>
    </xsl:template>
    </xsl:stylesheet>
    Hi Pullmeout,

    as said several times before in this thread, what you proporse is bad practice.

    Any time when trying to output xML constructs (like CDaTA section) and not using XSLT methods intended for that,
    something is wrong.

    cdata-section-elements attribute of <xsl:output .../>
    is in the spec to be used for CDaTA sections.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: disable-output-escaping CDATA problem

    ‏2013-03-06T14:43:42Z  
    • HermannSW
    • ‏2013-01-26T17:42:19Z
    Hi Pullmeout,

    as said several times before in this thread, what you proporse is bad practice.

    Any time when trying to output xML constructs (like CDaTA section) and not using XSLT methods intended for that,
    something is wrong.

    cdata-section-elements attribute of <xsl:output .../>
    is in the spec to be used for CDaTA sections.

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    Hermann,
    Thanks so much for your assistance!. I was able to work this out.
    I was on a vacation that's the reason for the delay ,... Thanks a ton!

    Regards,
    Salla