Project

Profile

Help

validation XSD 1.1 with eclispe is not working

Added by Mario Mueller over 6 years ago

Hi all,

I am trying to validate a XSD 1.1 I downloaded saxon-resources9-8.zip for having a sample validation java-program.

I also downloaded SaxonEE9-8-0-10J to get the relevant jar file and unzipped In eclipse > project properties > Java Build Path > Add external jars > I added:

  • icu4j-59_1.jar
  • saxon9ee.jar
  • saxon9ee-test.jar
  • saxon9-sql.jar

On https://www.saxonica.com/html/documentation/schema-processing/validation-api/schema-jaxp.html the documentation says "Saxon also provides the class SchemaFactory11 which automatically enables support for XSD 1.1. When the JAXP search mechanism is used, this schema factory will be selected if the schema language required is set to http://www.w3.org/XML/XMLSchema/v1.1."

When I start the SchemaValidatorHandlerExample.java, which is delivered in saxon-resources9-8.zip using an XSD 1.1 I am getting the error "Element 'assert' is invalid, misplaced, or occurs too often."

So it seems that not the 1.1-parser is used. Could anybody please explain what is ment by "if the schema language required is set to http://www.w3.org/XML/XMLSchema/v1.1." Where do I have to set http://www.w3.org/XML/XMLSchema/v1.1

Is there anything else I forgot?

I attached my java as well as the XSD1.1 and a sample XML

Many Thanks Regards Mario


Replies (2)

RE: validation XSD 1.1 with eclispe is not working - Added by Michael Kay over 6 years ago

You should specify the schema language as the first argument to SchemaFactory.newInstance().

Even better, make sure Saxon is loaded by either

(a) using the 3-argument form of SchemaFactory.newInstance(), with the Saxon SchemaFactory class ("com.saxonica.ee.jaxp.SchemaFactoryImpl") as the second argument, or

(b) use the constructor new com.saxonica.ee.jaxp.SchemaFactoryImpl(), or

(c) use s9api interfaces instead of JAXP (the main benefit is closer integration between the various XPath, XQuery, XSLT, and XSD APIs).

RE: validation XSD 1.1 with eclispe is not working - Added by Mario Mueller over 6 years ago

Hi Michael,

first of all: Many greetings from Gunther Stuhec__. I am working at the moment with him, I used variant (b) and it seems to work. Unfortunatelly we do not have a license at the moment, which I have to organize.

Regards Mario

    (1-2/2)

    Please register to reply