Tengo dos archivos de esquema, uno es importado del otro. Al ejecutar el código en los esquemas de Eclipse se encuentran, pero al ejecutar el código de archivos de esquema jar no se encuentranHacer referencia a un esquema XSD dentro del archivo jar
Este es el código
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(false);
SchemaFactory schemaFactory = SchemaFactory
.newInstance("http://www.w3.org/2001/XMLSchema");
try {
factory.setSchema(schemaFactory.newSchema(new Source[] {
new StreamSource(getClass().getResource("Liso.xsd")
.getFile()),
new StreamSource(getClass().getResource("LisoXml.xsd")
.getFile()) }));
this.saxParser = factory.newSAXParser();
} catch (SAXException se) {
System.out.println("SCHEMA : " + se.getMessage()); // problem in the XSD itself
}
y aquí está el error que consigo
SCHEMA : schema_reference.4: Failed to read schema document 'file:/C:/Tools/lib/LisoTools.jar!/com/xerox/liso/xml/Liso.xsd', because 1) could not find the do
cument; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
Gracias
Recuerdo que tuve un problema similar hace dos años: http://stackoverflow.com/questions/2065868/need-help-with-strange-classgetresource-issue- 'getRessource()' trabajado con Java 1.4.2 pero no con java 1.6 ... –
Verifique que su jar tenga '/ com/xerox/liso/xml/Liso.xsd' incluido y que parezca un xsd, también :) – rogerdpack