Hi James,
On Wed, 2011-03-16 at 12:37 +0000, James Abley wrote:
> On 16 March 2011 01:42, Andy Stevens <[email protected]>
> wrote:
> "Failed to read schema document 'null', 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>".
>
> The 'null' I assume is just because I haven't set a specific
> systemId on the
> StreamSource. However, the xsd file is certainly being found
> (I've checked
> the resource URL and that's fine) and can certainly be read
> (I've dumped the
> InputStream out to the console instead, and see the file's
> contents).
> However, the schema file is using "xs" as its prefix rather
> than "xsd"
> (with corresponding
> xmlns:xs="http://www.w3.org/2001/XMLSchema") so the root
> element is actually <xs:schema> not <xsd:schema>. So it looks
> like the
> error is due to the 3rd option it gives.
...
> How rigid is the Validator over the prefix being used, given
> the namespace
> URL itself is correct? Is the specific prefix hard-coded
> somewhere, or is
> there something I can do to make it check the actual namespace
> instead? Or,
> since the jaxp13.Validator in v1.3 says it can handle a
> variety of schema
> languages, is this error not being produced by XMLUnit anyway
> but by
> whatever default SchemaFactory it's using? And if so, is
> there anything I
> can do about it? (e.g. a configuration setting I can pass
> through to the
> SchemaFactory somehow) Given I didn't produce the schema
> files, and the
> fact there's quite a number of them involved, I'd prefer not
> to have to go
> through and find/replace the prefix in them all...
...
>
> Can you provide a stack trace?
>
>
> A brief inspection of the current svn HEAD hasn't shown that there is
> any hard-coded reference to xsd:schema in XMLUnit's source code.
Sure. I'd moved on from validating just the schema to try validating a
document instead, but was still seeing the same message in a nested
exception further down the stack trace...
org.custommonkey.xmlunit.exceptions.XMLUnitRuntimeException: Schema is
invalid
at
org.custommonkey.xmlunit.jaxp13.Validator.getInstanceErrors(Validator.java:176)
at
fixml.MessageBuilderTest.quickMessageTest(MessageBuilderTest.java:115)
...
Caused by: org.xml.sax.SAXParseException: schema_reference.4: Failed to
read schema document 'null', 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
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
Source)
at
org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown
Source)
at
org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown
Source)
at
org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown
Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown
Source)
at
org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown
Source)
at
org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown
Source)
at
org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown
Source)
at
org.custommonkey.xmlunit.jaxp13.Validator.parseSchema(Validator.java:202)
at
org.custommonkey.xmlunit.jaxp13.Validator.getInstanceErrors(Validator.java:174)
Based on that, I reckon the message is originally coming from Xerces.
But is there anything (e.g. feature or property) I can pass through to
it via the Validator API that might get it to behave better?
Andy
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Xmlunit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmlunit-general