[xml] No warnings if xsd:import files not found



Hi,

It seems xmllint doesn't give any notification if it's unable to load a file referenced in an xsd:import, and I wondered if this was intentional, because it just carries on blindly and this results in confusing errors.

For example, I'm testing under OSX using the schema and examples in this file:

http://www.niccstandards.org.uk/files/current/nd1641v1.1.1.zip?type=zip

After unzipping this, I'm doing:

$ xmllint --noout --schema Schemas/NICC-common/NICC-Fulfilment-v1-0.xsd L2C/Examples/OrderStatusUpdate\ -\ EUAC\ -\ Provide\ -\ KCI1.xml

which gives a bunch of errors starting with:

Schemas/NICC-common/NICC-Fulfilment-v1-0.xsd:59: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'ref': The QName value '{urn:uk.org.NICC/tML/Fulfilment/NICC-Order-v1-0}Order' does not resolve to a(n) element declaration. Schemas/NICC-common/NICC-Fulfilment-v1-0.xsd:65: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'ref': The QName value '{urn:uk.org.NICC/tML/Fulfilment/NICC-OrderAmendment-v1-0}OrderAmendment' does not resolve to a(n) element declaration.
... snip many more ...

Now, Schemas/NICC-common/NICC-Fulfilment-v1-0.xsd contains the following:

<xsd:import namespace="urn:uk.org.NICC/tML/Fulfilment/NICC-Order-v1-0" schemaLocation="..\maindoc\NICC-Order-v1-0.xsd"/>
...
        <xsd:complexType name="AddOrder">
                <xsd:sequence>
<xsd:element ref="ord:Order"/> <<<< this is what fails
                </xsd:sequence>
        </xsd:complexType>

and Order is defined in NICC-Order-v1-0.xsd

You can see that the xsd:import uses a relative path with Windows-style backslash path separators. If I change all the backslashes to forward slashes, lo and behold, the file validates!

$ xmllint --noout --schema Schemas2/NICC-common/NICC-Fulfilment-v1-0.xsd L2C/Examples/OrderStatusUpdate\ -\ EUAC\ -\ Provide\ -\ KCI1.xml
L2C/Examples/OrderStatusUpdate - EUAC - Provide - KCI1.xml validates

But this would have been much easier to debug if xmllint had given at least a warning that it had tried to locate a file to import, and failed.

Adding --debug or --debugent doesn't provide such a warning. Adding --load-trace shows only

Loaded URL="Schemas/NICC-common/NICC-Fulfilment-v1-0.xsd" ID="(null)"

but gives no indication that it attempted to load any other file. Once I fix the slashes, I can see it loading all the schema files:

Loaded URL="Schemas2/NICC-common/NICC-Fulfilment-v1-0.xsd" ID="(null)"
Loaded URL="Schemas2/maindoc/NICC-Order-v1-0.xsd" ID="(null)"
Loaded URL="Schemas2/NICC-common/NICC-CommonAggregateComponents-v1-0.xsd" ID="(null)"
... etc

Am I missing something? Is there a flag to get a warning on failed imports?

Thanks,

Brian Candler.

P.S. This was tested with the xmllint included in OSX 10.9.5, and also 2.9.1 compiled using homebrew.

$ xmllint --version
xmllint: using libxml version 20900
compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib
$ /usr/local/Cellar/libxml2/2.9.1/bin/xmllint --version
/usr/local/Cellar/libxml2/2.9.1/bin/xmllint: using libxml version 20901
compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]