Two Laptop Bag
The moose likes XML and Related Technologies and the fly likes Schema Location H*ll 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 "Schema Location H*ll" Watch "Schema Location H*ll" New topic

Schema Location H*ll

john hartley

Joined: Oct 22, 2003
Posts: 5
I am attempting to do basic schema-validation of xml data using a DOMParser, (latest Apache).
I am using an InputSource wrapping a byte[] full of XML data, i.e. not an XML file.
When validation is turned OFF, the parser is happy and parses the data fine. But when trying to validate the data, the parser always throws the SAXExceptions
"Document is invalid: no grammar found." and
"Document root element "transmittal", must match DOCTYPE root "null".
...implying to me that it cannot locate either the schema schema or the instance schema
The root node attributes in the XML data are:
<rootNodeName xmlns:xsi=""
I have tried every form for specifying the noNamespaceSchemaLocation that I can think of...
For example:
- fully qualified path
- "file:rootNodeName.xsd"
- setting the systemId (of the InputSource) to the base path of the schema
file location
- ???
Any ideas on how I have to specify this information?
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
How are you turning validation on? Are you setting features?
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
As Jason implied, perhaps you have forgotten to set the feature for *schema* validation ("").

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
john hartley

Joined: Oct 22, 2003
Posts: 5
Lasse, thanks. I overlooked that feature. With so many features, I am easily confused. Early indications are that it is working.
Thanks again,
I agree. Here's the link:
subject: Schema Location H*ll
It's not a secret anymore!