[XML] XSD Schema Validation

M

Martin Honnen

Roedy Green wrote:

I was enshrining a heavily commented variant of your code as an
example at http://mindprod.com/jgloss/xsd.html

That has

// get the custom xsd schema describing the required format for my XML
files.
Schema schemaXSD = schemaFactory.newSchema( new File ( "myschema.xsd" ) );

// hook up org.xml.sax.ErrorHandler implementation.
schemaFactory.setErrorHandler( myErrorHandler );

but you should set up the error handler first on the schema factory and
then call newSchema e.g.

// hook up org.xml.sax.ErrorHandler implementation.
schemaFactory.setErrorHandler( myErrorHandler );

// get the custom xsd schema describing the required format for my XML
files.
Schema schemaXSD = schemaFactory.newSchema( new File ( "myschema.xsd" ) );

if the aim is to have the error handler report any problems found while
parsing and compiling myschema.xsd.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top