How to check XML for XSD schema containing import without schema location?
XSD snippet:
<xs:schema xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.microsoft.com/exchange/services/2006/types" elementFormDefault="qualified" version="Exchange2010_SP2" id="types"> <xs:import namespace="http://www.w3.org/XML/1998/namespace"/> ...
Already read and tried:
This one and this one too ... Unsuccessful.
This import cannot be removed from the schema because it contains a reference to the xml: lang attribute.
In option 1, ResourceResolver resolveResource method launched using systemId = null
public class ResourceResolver implements LSResourceResolver { public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
In option 2 I tried like this:
SchemaFactory sFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); //sFactory.setResourceResolver(new ResourceResolver()); Schema schema = sFactory.newSchema(new Source[] { new StreamSource("http://www.w3.org/XML/1998/namespace"), new StreamSource(MailGateMQBinding.class.getResourceAsStream("/types.xsd")), }); validator = messageSchema.newValidator(); source = new DOMSource(inDocBody); validator.validate(source);
But there is an exception: without new StreamSource("http://www.w3.org/XML/1998/namespace") org.xml.sax.SAXParseException: src-resolve: cannot resolve the name "xml: lang" in the attribute declaration (n) ".
and with this new StreamSource("http://www.w3.org/XML/1998/namespace") org.xml.sax.SAXParseException: s4s-elt-character: characters without spaces are not allowed in scheme elements other than ' xs: appinfo 'and' xs: documentation '.. Saw' The "xml:" Namespace.
Any help would be greatly appreciated.
source share