[jdom-interest] Turning off validation against a DTD
Philip Nelson
panmanphil at yahoo.com
Tue Sep 10 18:13:16 PDT 2002
It doesn't "validate" against the dtd if you tell it not to. It does still
parse the dtd, parse entities, load default attribute values etc. because
that's what dtd's are for. Certain parser flags may be available for certain
parsers to limit this somewhat, but that's beyond what jdom has any control
over.
--- "Indrayan, Rahul" <rindrayan at ets.org> wrote:
> I have the following 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(); }
> }
> }
>
> I do not want to validate the XML in this case, and therefore I do:
> SAXBuilder builder = new SAXBuilder(false). However, initializing builder
> with the false parameter, it still validates it against the DTD.
> How can I turn off validation and just make it write the XML to a file?
>
> 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
__________________________________________________
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost
http://dir.remember.yahoo.com/tribute
More information about the jdom-interest
mailing list