I need to validate XML files against XSD 1.1 schema. My question is: Does the Xerces library supports now XSD 1.1?
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.2</version>
</dependency>
When i include this in my pom then it doesnot work . It gives following Error :
java.lang.IllegalArgumentException: No SchemaFactory that implements the schema language specified by: http://www.w3.org/XML/XMLSchema/v1.1 could be loaded
But when i add the following jars manually in classpath then it kinda works:
cupv10k-runtime.jar
org.eclipse.wst.xml.xpath2.processor_1.1.0.jar
xercesImpl.jar
xml-apis.jar
My Code :
import javax.xml.validation.SchemaFactory;
schemaFactory = SchemaFactory.newInstance("http://www.w3.org/XML/XMLSchema/v1.1");
Do we need to add the jars manually for this to work. Isn't the library avialable in maven? Plese help if anyone has any idea.
CodePudding user response:
The blog article https://blog.adamretter.org.uk/xerces-xsd11-maven/ describes the dilemma and explains that the author set up https://search.maven.org/artifact/org.exist-db.thirdparty.xerces/xercesImpl/2.12.2/jar and that that way you can use e.g.
<dependency>
<groupId>org.exist-db.thirdparty.xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.2</version>
<classifier>xml-schema-1.1</classifier>
</dependency>
<!-- xpath2 and java-cup are needed at runtime
for xercesImpl Schema 1.1 support -->
<dependency>
<groupId>org.exist-db.thirdparty.org.eclipse.wst.xml</groupId>
<artifactId>xpath2</artifactId>
<version>1.2.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>edu.princeton.cup</groupId>
<artifactId>java-cup</artifactId>
<version>10k</version>
<scope>runtime</scope>
</dependency>