Xerces v2.12.0 XML Schema 1.1 Validation

2.2k views Asked by At

Xerces 2.12.0 claims to support XSD 1.1 (https://xerces.apache.org/xerces2-j/faq-xs.html), but I can't get past the SchemaFactory.newInstance call.

More context:

This line fails:

import javax.xml.validation.SchemaFactory;
//...
schemaFactory = SchemaFactory.newInstance("http://www.w3.org/XML/XMLSchema/v1.1");

With the exception:

java.lang.IllegalArgumentException: No SchemaFactory that implements the schema language specified by: http://www.w3.org/XML/XMLSchema/v1.1 could be loaded

Here's the maven dependency I'm using:

<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.12.0</version>
</dependency>

While I've found several posts claiming this works, it doesn't for me.

I've seen folks recommending this very old dependency:

<dependency>
    <groupId>org.opengis.cite.xerces</groupId>
    <artifactId>xercesImpl-xsd11</artifactId>
    <version>2.12-beta-r1667115</version>
</dependency>

And yeah, that kinda works, but I'd prefer using the Apache version, especially since it claims to support XSD 1.1.

2

There are 2 answers

1
Michael Glavassevich On BEST ANSWER

Xerces-J 2.12.0 has two distributions: one (Xerces-J-bin.2.12.0-xml-schema-1.1.zip) that contains XML Schema 1.1 support and one (Xerces-J-bin.2.12.0.zip) that does not. Your Maven dependency seems to be pointing to the Xerces 12.2.0 jar without XML Schema 1.1 support. As of today, I don't think the XML Schema 1.1 version got published to Maven.

The Apache community has been helping with making Xerces available in Maven repos. You may want to bump the discussion here: https://issues.apache.org/jira/browse/XERCESJ-1695.

0
David L. On

I've found:

<!-- https://mvnrepository.com/artifact/org.ibissource/ibis-xerces -->
<dependency>
    <groupId>org.ibissource</groupId>
    <artifactId>ibis-xerces</artifactId>
    <version>2.12.2-xml-schema-1.1</version>
</dependency>