You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Magnus Heino <mh...@gmail.com> on 2007/02/22 21:28:12 UTC
javax.xml.validation.Schema and schemaLocation
Hi.
SchemaFactory schemaFactory =
(XMLSchemaFactory) SchemaFactory.newInstance(
XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(schemaSource.toArray(new
StreamSource[schemaSource.size()]));
schemaSource is a list of StreamSources.
I get this error when I call newSchema:
2007-02-22 21:17:12,059 [main] WARN Parser warning systemId:'null', row '4'
column '93'.schema_reference.4: Failed to read schema document
'gml/v3.1.1/feature.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>. at
se.lantmateriet.elips.poc.xml.validation.SchemaValidator$1.warning(
SchemaValidator.java:74)
2007-02-22 21:17:12,059 [main] WARN Parser warning systemId:'null', row '5'
column '93'.schema_reference.4: Failed to read schema document
'gml/xlink/xlinks.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>. at
se.lantmateriet.elips.poc.xml.validation.SchemaValidator$1.warning(
SchemaValidator.java:74)
2007-02-22 21:17:12,074 [main] ERROR Parser error systemId:'null', row '13'
column '59'.src-resolve: Cannot resolve the name
'gml:AbstractFeatureCollectionType' to a(n) 'type definition' component. at
se.lantmateriet.elips.poc.xml.validation.SchemaValidator$1.error(
SchemaValidator.java:62)
I understand that it can't resolve 'gml/v3.1.1/feature.xsd' since I add
StreamSources, but what is the correct way to resolve this?
If I add a resource resolver like this:
schemaFactory.setResourceResolver(new LSResourceResolver() {
public LSInput resolveResource(String type, String namespaceURI,
String publicId, String systemId, String baseURI) {
logger.debug("type: " + type + " namespaceURI: " +
namespaceURI + " publicId: " + publicId + " systemId: " + systemId + "
baseURI:" + baseURI);
return null;
}});
then I get this output:
2007-02-22 21:24:37,277 [main] DEBUG type:
http://www.w3.org/2001/XMLSchemanamespaceURI:
http://www.opengis.net/gml publicId: null systemId: gml/v3.1.1/feature.xsd
baseURI:null at
se.lantmateriet.elips.poc.xml.validation.SchemaValidator$1.resolveResource(
SchemaValidator.java:64)
2007-02-22 21:24:37,293 [main] WARN Parser warning systemId:'null', row '4'
column '93'.schema_reference.4: Failed to read schema document
'gml/v3.1.1/feature.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>. at
se.lantmateriet.elips.poc.xml.validation.SchemaValidator$2.warning(
SchemaValidator.java:83)
2007-02-22 21:24:37,293 [main] DEBUG type:
http://www.w3.org/2001/XMLSchemanamespaceURI:
http://www.w3.org/1999/xlink publicId: null systemId: gml/xlink/xlinks.xsd
baseURI:null at
se.lantmateriet.elips.poc.xml.validation.SchemaValidator$1.resolveResource(
SchemaValidator.java:64)
2007-02-22 21:24:37,293 [main] WARN Parser warning systemId:'null', row '5'
column '93'.schema_reference.4: Failed to read schema document
'gml/xlink/xlinks.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>. at
se.lantmateriet.elips.poc.xml.validation.SchemaValidator$2.warning(
SchemaValidator.java:83)
2007-02-22 21:24:37,293 [main] ERROR Parser error systemId:'null', row '13'
column '59'.src-resolve: Cannot resolve the name
'gml:AbstractFeatureCollectionType' to a(n) 'type definition' component. at
se.lantmateriet.elips.poc.xml.validation.SchemaValidator$2.error(
SchemaValidator.java:71)
What should I do in the resolveResource method?? I really don't see the
solution here...
Thanks!
--
/Magnus Heino