Open paulhiggs opened 4 years ago
Here is the most simple example to reproduce the error
let recipe_xsd=`<?xml version="1.0" encoding="utf-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:r="http://www.namespace.org/recipe" xmlns:s="http://www.namespace.org/servings" targetNamespace="http://www.namespace.org/recipe" version="1.0" elementFormDefault="unqualified" attributeFormDefault="unqualified">
<import namespace="http://www.namespace.org/servings" schemaLocation="serving.xsd"/>
<element name="recipe" type="r:recipe"/>
<complexType name="recipe">
<sequence>
<element name="servings" type="s:servingsType"/>
</sequence>
</complexType>
</schema>`;
let serving_xsd=`<?xml version="1.0" encoding="utf-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:rx="http://www.namespace.org/servings" targetNamespace="http://www.namespace.org/servings" elementFormDefault="unqualified" attributeFormDefault="unqualified" version="1.0">
<element name="guests" type="rx:servingsType"/>
<simpleType name="servingsType">
<restriction base="unsignedInt">
<minInclusive value="1"/>
<maxInclusive value="16"/>
</restriction>
</simpleType>
</schema>`;
let recipe_xml=`<?xml version="1.0"?>
<r:recipe xmlns:r="http://www.namespace.org/recipe" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.namespace.org/recipe recipe.xsd">
<servings>12</servings>
</r:recipe>`;
The XML document uses a recipe schema (recive_1) which in turn uses a datatype defined in a second schema (recipe_2).
with
let e3 = xmllint.validateXML({xml:recipe_xml, schema: [recipe_xsd, serving_xsd ]});
console.dir(e3);
we get the output
{
errors: [
"file_0.xml:2: element recipe2: Schemas validity error : Element '{http://www.namespace.org/recipe}recipe2': No matching global declaration available for the validation root."
]
}
swapping the order of elements in the list of shemas to schema: [recipe2_xsd, recipe1_xsd ]
gives
{
errors: [
"file_1.xsd:7: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.namespace.org/servings' are not allowed, since not indicated by an import statement."
]
}
I am trying to use xmllint to validate an XML document against a set of schemas and get the following error:
Line 26 of the XML document is
and the node/express code being used is
the "sample" files can be found in https://github.com/paulhiggs/dvb-sl-check/tree/master/sample the "schema" files can be found in https://github.com/paulhiggs/dvb-sl-check/tree/master/schema
The XML document validates OK with XMLspy 2019