xsl-list
[Top] [All Lists]

[xsl] disable out escaping for the CDATA section

2008-11-14 02:45:23
Hi All,

I need some clarification to use disable-output-escaping attribute in XSL.

Here is my sample XML

<?xml version="1.0" encoding="UTF-8" ?>
<PurchaseOrder OrderDate="2008-11-14" xmlns="http://www..oracle.com/pcbpel/po";>
   <ID xmlns="">ID66&lt;</ID>
   <script>
        <![CDATA[
          if (a < b && a < 0) then {
           return 1;
          else
           return 0;
        ]]>
</script>
</PurchaseOrder>

And my XSL has the following code

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <!-- Root template -->
  <xsl:template match="/">
  <xsl:apply-templates/>
  </xsl:template>
<xsl:template match="script">
   <xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>
<xsl:template match="ID">
   <xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>  
</xsl:stylesheet>

While generating the output to XML or HTML and then see the view source.. it 
has the following output

<?xml version="1.0" encoding="UTF-16"?>ID66<

          if (a &lt; b &amp;&amp; a &lt; 0) then {

           return 1;

          else

           return 0;

 Why the result from CDATA section shows as &lt; instead of < and &amp; instead 
of &  even though i have used d-o-e yes ?

Refered http://www.dpawson.co.uk/xsl/sect2/N2215.html#d3989e280
Conversely <![CDATA only quotes < and & in the input: it has no effect
on the output, <![CDATA[ < ]]> will be output as &lt; unless d-o-e is
used.

Regards,
Arul



      Be the first one to try the new Messenger 9 Beta! Go to 
http://in.messenger.yahoo.com/win/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--