[jdom-interest] Turning of entity expansion

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Sep 4 05:53:50 PDT 2002


At 7:21 AM +0100 9/4/02, ion wrote:
>Here is an example, consider the following simple program:

This is helpful. Thanks! As I suspected, you're trying to shoot 
yourself in the foot. The first problem is this line:

>       body.addContent(new Element("p").setText("" © blah blah"));

It should read:

       body.addContent(new Element("p").setText("\" \u00A9 blah blah"));

In Java String literals you have to use Java escaping, not XML 
escaping. JDOM will convert whatever String you give it to XML text 
and escape it as necessary on output.


>How can I output an amphersand verbatim?
>

You absolutely cannot because this would be malformed XML. JDOM does 
not let you create malformed XML, nor should you want to.

-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          XML in a  Nutshell, 2nd Edition (O'Reilly, 2002)          |
|              http://www.cafeconleche.org/books/xian2/              |
|  http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/  |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list