Java.lang.IllegalArgumentException: No SchemaFactory that implements the specified schema language

I get the following exception:

java.lang.IllegalArgumentException: No SchemaFactory that implements the schema language specified: http://www.w3.org/2001/XMLSchema-instance can be loaded in javax.xml.validation.SchemaFactory.newInstance (SchemaFactory.java:204 ) in MAIN.SchemaImport3.validateXMLSchema (SchemaImport3.java:74) in MAIN.SchemaImport3.main (SchemaImport3.java:62)

Here is my code:

URL source; source = new URL(schemaList.getDocumentBaseURI()); SchemaFactory factory = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI); 
+6
source share
1 answer

Use XMLConstants.W3C_XML_SCHEMA_NS_URI :

 SchemaFactory factory = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI ); 

The URI " http://www.w3.org/2001/XMLSchema-instance " (value XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI ) is not an XML schema language per se, but a property (or function or additional mechanism, if you want) of an XML schema.

The proper name for the W3C XML Schema is: http://www.w3.org/2001/XMLSchema "(value XMLConstants.W3C_XML_SCHEMA_NS_URI ).

+9
source

All Articles