[jdom-interest] [Q} & in data for addContent() and setText()

Rob Mitchell rjmitchell at mediaone.net
Mon Jan 14 08:20:25 PST 2002


I checked FAQ on dom.org -- no good match.
Now, should I try to translate "&" to "&" when creating the XML document from SQL?

I'm using JDBC to get data from some database.  Often, I get the ampersand character in names from the resultset and format into XML like this:

  <cps:RECORD cps:RECORDCOUNT="1">
    <cps:orgnzn_name>B SCOTT & WHITE TRUST</cps:orgnzn_name>

This output is from XMLOutputter 

  String strText = null;
  try {
   XMLOutputter outputter = new XMLOutputter("  ", true);
   StringWriter writer = new StringWriter();
   outputter.output (aDoc, writer);
   strText = writer.toString();
  } catch (java.io.IOException e) {
  } catch (Exception e) {
  return strText;

When I try to apply XSL template, I get error because of the "&" character in orgnzn_name in the XML, actually it doesn't even translate because the engine thinks there's an invalid whitespace.

Suggestions welcome.


Rob Mitchell
rjmitchell at mediaone.net
Base Class Technologies, Inc.
Designing and developing Java/Oracle solutions for the Web

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020114/4adf254c/attachment.htm

More information about the jdom-interest mailing list