[jdom-interest] DOMBuilder validation -api error in DOMBuilder.java

Brett McLaughlin brett.mclaughlin at lutris.com
Thu Jun 15 08:53:30 PDT 2000


philip.nelson at omniresources.com wrote:
> 
> >
> >      DOMBuilder builder = new DOMBuilder(true);
> >                               /*         ^^^^       */
> >                               /* Turn on validation */
> >      // start parsing...
> >      DOMParser parser = new DOMParser();  // Xerces specific class
> >      for (int i = 0; i < args.length; i++) {
> >
> >        try {
> >          // Read the entire document into memory
> >          parser.parse(args[i]);
> >
> >          org.w3c.dom.Document domDoc  = parser.getDocument();
> >          org.jdom.Document    jdomDoc = builder.build(domDoc);
> 
> Interesting.  The DOMBuilder class has the flag for validation but never
> uses it anywhere.   The reason it doesn't use is that the DOMBuilder doesn't
> do any parsing; it's handed a DOM tree and the parsing has already happened.
> It's the adapter that has to do the validation.  Here is slightly modified
> code from the DOMBuilder sample to correctly turn validation on and off.
> 
> DOMAdapter domadapter;
> FileInputStream in = new FileInputStream(filename);
> try {
>         Class parserClass = Class.forName(domAdapterClass);
>         domadapter = (DOMAdapter)parserClass.newInstance();
> } catch (ClassNotFoundException e) {//stuff here}
> 
> // Build the JDOM Document - validating is off by default for this example
> // because of the document root issue
> 
> boolean validate = true;
> org.w3c.dom.Document w3cdoc = domadapter.getDocument((InputStream)in,
> validate);
> Document doc = builder.build(w3cdoc);

You're right as to the problem, Philip - however, I would rather
DOMBuilder internally pass the flag on to the adapater rather than
forcing the user to do it... I'll try and get this stuff into the tree
today...

-Brett

> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin
Enhydra Strategist
Lutris Technologies
1200 Pacific Avenue
Santa Cruz, CA  95060



More information about the jdom-interest mailing list