You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by "Robert J. Wygand III" <ro...@wygand.com> on 2000/05/02 01:56:30 UTC

Disable Output Escaping?

Hi,

I am using both Xerces and Xalan in a Servlet environment. I'm having
the following problem, though:

I need to allow a user to type in some data into an html textarea field.
This text MAY be html.

I then need to preview this html-text back to the user. Using the DOM, I
write out an xml construct using the following code:

...
Element body = doc.CreateElement ("Body");      // doc is a Document
message.appendChild (body);
Node bodyText = doc.createCDATASection (_body); // _body is a String set
to <b>123</b>
body.appendChild (bodyText);
...

which outputs the following:

<?xml version="1.0"?>
<?xml-stylesheet href="/html_preview.xsl"?>

<Page>
  <Message>
    <Body>
      <CDATA[[<b>123</b>]]>
     </Body>
  </Message>
</Page>

When I try and style this document using Xalan, I cannot get it to pass
the CDATA section through unencoded. My styling rule looks like this...

<xsl:template match="Preview">
  <table border="0" cellpadding="4" cellspacing="0" width="100%">
    <tr bgcolor="#FFFFFF">
      <td valign="top">
        <table border="0" cellpadding="6" cellspacing="0" width="100%">
          <tr>
            <td colspan="2" height="100%">
              <xsl:value-of select="/Page/Composer/Message/Body"
                   disable-output-escaping="yes"/>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</xsl:template>

I've also tried seting the cdata-section-elements attribute of the
xsl:output element to "Body". Additionally, I've tried both
doc.createTextNode() and doc.createCDATASection() in the java code.

Any ideas what I am doing wrong, or if I've hit a bug or an
unimplemented feature?

Thanks!
rob
rob@wygand.com