[jdom-interest] How to not expand entities?
David Kavanagh
dak at dotech.com
Tue Sep 10 18:00:21 PDT 2002
I think you need to extend XMLOutputter. You can override
escapeElementEntities() to escape the character ranges you are
interested in (perhaps those with values over 127?).
David
Indrayan, Rahul wrote:
>Again, a question related to the same code: -
>
>import java.io.*;
>import org.jdom.*;
>import org.jdom.input.*;
>import org.jdom.output.*;
>
>public class Spike {
> public static void main(String args[]) {
> try {
> SAXBuilder builder = new SAXBuilder(false);
> builder.setExpandEntities(false);
> String xml = "<?xml version=\"1.0\"
>encoding=\"UTF-8\"?><!DOCTYPE root SYSTEM \"foo.dtd\"><root><proof>This is
>á foofoo ó stuff!</proof></root>";
> new XMLOutputter().output(
> builder.build(new StringReader(xml)),
> new PrintWriter(new
>FileWriter("c:\\proof.xml")));
> }
> catch (Exception e) { e.printStackTrace(); }
> }
>}
>
>
>How do I output the XML to a string so that unicode such as á does not
>get expanded and the file represent the special characters with their
>unexpanded equivalents (i.e., á)?
>
>Thanks!
>
>
>
>**************************************************************************
>This e-mail and any files transmitted with it may contain privileged or
>confidential information. It is solely for use by the individual for whom
>it is intended, even if addressed incorrectly. If you received this e-mail
>in error, please notify the sender; do not disclose, copy, distribute, or
>take any action in reliance on the contents of this information; and delete
>it from your system. Any other use of this e-mail is prohibited. Thank you
>for your compliance.
>
>
>
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>
More information about the jdom-interest
mailing list