• 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

SAX parse and validate with XSD

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am using SAX to parse a huge doc.
my Q is: How to set that Validation must occur?

The xerces parser I use seems to be only checking well-formedness, but noth validation ; although I force it to do so:

Approach 1:
in the root element of the XML Document.
PS:By default the XML Docs I receive do not have either noNamespaceSchemaLocation or schemaLocation set. so I added them manually programmatically just to be able to test; by using reader.set(..., ...);


Approach 2:
within the SAX Parser:

PS: THE TARGETNAMESPACE OF THE XSD DOC and the DEFAULT NAMESPACE OF THE RECEIVED Instance XML DOC ARE THE SAME; I guess this means I should NOT use noNamespaceSchemaLocation. Am I right?
also, xsi:schemaLocation="http://www.R�STEM.RU/XYZ.KUR file:/C:/schemas/schema1.xsd" this can or cannot exist in the XML Instance document. it should not make any difference. is this also correct?
In the Xerces web site, it claims when one programmatically defines the schema location, then the schemaLocation on the XML instance document (if ever exists) will be overwritten..


Thx
R�stem
[ January 26, 2005: Message edited by: R�stem-� Zal� ]
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried leaving just one (1) space between "http://www.RUSTEM.RU/XYZ.KUR" and "XSDSchemaURI" for the "http://apache.org/xml/properties/schema/external-schemaLocation" property?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
Have you tried leaving just one (1) space between "http://www.RUSTEM.RU/XYZ.KUR" and "XSDSchemaURI" for the "http://apache.org/xml/properties/schema/external-schemaLocation" property?



Thx, I solved the problem.
it was that in the web application I get the location of the XSD File using but the web application context name contained spaces, so it is interpreted as having more than 1 Namespaces and so accompanying schemas...
 
reply
    Bookmark Topic Watch Topic
  • New Topic