aspose file tools*
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Schema Location H*ll" Watch "Schema Location H*ll" New topic
Author

Schema Location H*ll

john hartley
Greenhorn

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="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="rootNodeName.xsd">
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?
TIA
jr
jason adam
Chicken Farmer ()
Ranch Hand

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

Joined: Jan 23, 2002
Posts: 11962
    
    5
As Jason implied, perhaps you have forgotten to set the feature for *schema* validation ("http://apache.org/xml/features/validation/schema").


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

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,
jr
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Schema Location H*ll