• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Schema Location H*ll

 
john hartley
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1932
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you turning validation on? Are you setting features?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Jason implied, perhaps you have forgotten to set the feature for *schema* validation ("http://apache.org/xml/features/validation/schema").
 
john hartley
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lasse, thanks. I overlooked that feature. With so many features, I am easily confused. Early indications are that it is working.
Thanks again,
jr
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic