xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert J. Wygand III" <...@wygand.com>
Subject Disable Output Escaping?
Date Mon, 01 May 2000 23:56:30 GMT
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

Mime
View raw message