Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am getting the following exception:

java.lang.IllegalArgumentException: No SchemaFactory that implements the schema language specified by: http://www.w3.org/2001/XMLSchema-instance could be loaded at javax.xml.validation.SchemaFactory.newInstance(SchemaFactory.java:204) at MAIN.SchemaImport3.validateXMLSchema(SchemaImport3.java:74) at 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);
like image 735
user2176576 Avatar asked Mar 20 '14 09:03

user2176576


1 Answers

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 of the XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI) is not an XML schema language by itself, but a property (or feature, or additional mechanism, if you like) of the XML Schema.

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

like image 110
Oleg Estekhin Avatar answered Oct 23 '22 20:10

Oleg Estekhin