• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Schema Validation with Xerces

 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This concerns a problem with parsing an XML instance with it's schema using Xerces as the parser and a SAXParser object.

There is a annoying "no grammar found" error message when attempting to parse the file.

The schema is in the same directory as the instance file.

We are setting the validation feature to true and setting the file-name of the schema in the schemaLocation attribute after the namespace (see below).



Is there a bug with the schemaLocation attribute?

Is there a better way to specify the schema location?

Note, the file is being parsed for well-formedness. But, it is not being validated with the schema.

Any help is greatly appreciated.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

James Clark wrote:The schema is in the same directory as the instance file.


And are you parsing the XML document in such a way that the parser can tell what directory it's in? (If you give the parser a FileInputStream, for example, it can't generate a base URI from that and therefore can't find the parser relative to the base URI.)
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.

And are you parsing the XML document in such a way that the parser can tell what directory it's in?



That is what I am asking about. I am not using a FileInputStream object. Below is the method.

 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well... not that I think it's going to help... but you could try
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul.

There isn't much time to waste fighting with Xerces. We have switched to the javax.xml.validation API which uses three objects to validate documents: SchemaFactory, Schema, and Validator.




I imagine that it is using the Xerces implementation that comes bundled in the Java SDK. There probably is some method that will allow us to switch to the Apache version.


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic