[jdom-interest] In-Memory Validation - was: Validation using DOMBuilder

Kevin.Bedell at sunlife.com Kevin.Bedell at sunlife.com
Thu May 2 10:37:53 PDT 2002



Gosh -

I'd say calling this "the poor man's" method is selling it short. This is
"in-memory validation" after all.

Plus, you have the advantage of using the sax parser for validation, even
if you convert from a DOM object (or even if I create a jdom Document from
scratch). SAX Parser validation is a known quantity and is already
pluggable in the architecture. And it doesn't require validation to be
written into jdom.

Using a sax parser for validation gives the user the ability to adopt
whichever sax parser provides the validation capability they want. And if
the parser were to provide varying levels of validation based on how the
user configures it, you'd get that capability as well.

Besides - why not let the parser builders maintain the validation code and
put resources into other things...

So, given that lead up - why not just wrap this functionality into the
appropriate jdom class and call it "in memory validation"? It would sure be
quick to develop. Plus, I think the flexibility of being able to plug
whichever parser for validation is superior to writing it into jdom
directly anyway.


K.

 | Jason Hunter wrote:
 |
 |
| Yep, that's the poor man's method.
|
| -jh-
|


Kevin.Bedell at sunlife.com wrote:
>
> Thanks for the reply.
>
> Does it then stand to reason that something like this may work:
>
>      org.jdom.input.DOMBuilder jdomBuilder = new
org.jdom.input.DOMBuilder();
>      org.jdom.Document requestJDOMDoc = jdomBuilder.build(requestDOMDoc);
>
>      org.jdom.Document tmpDoc = requestJDOMDoc;
>
>       XMLOutputter fmt = new XMLOutputter();
>       String xml = fmt.outputString(tmpDoc);
>
>       // Recreate the document, this time performing validation
>       SAXBuilder saxBuilder = new SAXBuilder();
>       newDoc = saxBuilder.build(new StringReader(xml));
>
> I know I'm missing the lines where I set the DTD, etc. But would this
basic idea work?
>
> It would still be better than performing "manual" validation of the
xml....
>
> Jason Hunter <jhunter at acm.org> on 05/01/2002 03:16:10 PM
>
> To:   Kevin.Bedell at sunlife.com
> cc:   jdom-interest at jdom.org
> Subject:  Re: [jdom-interest] Validation using DOMBuilder
>
> The only validators out now are those that validate file content when
> they're loaded into memory.  There's someone working on a validator that
> operates in memory, and that would be the ideal solution for you.  Right
> now you want to validate, with JDOM or any API, you'll need to convert
> to bytes and read in from bytes.  Yep, it's lousy, and that's why we're
> doing something about it!
>
>

---------------------------------------------------------------------------
This e-mail message (including attachments, if any) is intended for the use
of the individual or entity to which it is addressed and may contain
information that is privileged, proprietary , confidential and exempt from
disclosure.  If you are not the intended recipient, you are notified that
any dissemination, distribution or copying of this communication is
strictly prohibited.  If you have received this communication in error,
please notify the sender and erase this e-mail message immediately.
---------------------------------------------------------------------------





More information about the jdom-interest mailing list