Meaningless Drivel is fun!
The moose likes XML and Related Technologies and the fly likes Validate on the fly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Validate on the fly" Watch "Validate on the fly" New topic

Validate on the fly

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270

I am building a XML document on the fly and want to validate the document before storing the file in the database. But when I try to validate it using saxBuilder I got an error even that I know the XML document is alright.

org.jdom.input.JDOMParseException: Error on line 2: cvc-elt.1: Cannot find the declaration of element 'Invoice'.

It seems that something goes wrong when validating the ByteArray:
Document d = new ByteArrayInputStream( buff ) );

Can you help me correct the code?

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Looks to me like your document uses a schema, but the parser can't find the schema. Have a look at where the document points to the schema.
I agree. Here's the link:
subject: Validate on the fly
It's not a secret anymore!