xs:import-schema with no namespace attribute reports no error if target schema document has a targetNamespace
The rules for xs:import in XSD 1.1 part 1 section 126.96.36.199 say
3 If D2 [the target document] exists, that is, clause 2.1 or clause 2.2 above were satisfied, then the appropriate case among the following must be true: 3.1 If there is a namespace [attribute], then its ·actual value· is identical to the ·actual value· of the targetNamespace [attribute] of D2. 3.2 If there is no namespace [attribute], then D2 has no targetNamespace [attribute]
xsl:import-schema effectively inherits these rules, because the semantics of xsl:import-schema are described in terms of an equivalent "synthetic schema document" using xs:import.
I believe we are not detecting condition 3.2, that is, the case where xsl:import-schema specifies no namespace attribute, and the referenced schema document has a targetNamespace. New test case import-schema-201 confirms this.
For xs:import itself, we get this right - as shown by new test case target007 in XSD test set targetNS.
Possible reason, in SchemaCompiler.processSchemaDocument(), it gets tangled up with the rules for chameleon include.
This is a spin-off of bug #3925
#1 Updated by Michael Kay about 3 years ago
- Subject changed from xs:import and xs:import-schema with no namespace attribute report no error if target schema document has a targetNamespace to xs:import-schema with no namespace attribute reports no error if target schema document has a targetNamespace
- Description updated (diff)
#2 Updated by Michael Kay about 3 years ago
The reason is the code in SchemaCompiler.processSchemaDocument()
if (expected != null && expected.length() > 0 && !expected.equals(targetNamespace))
which bypasses the check if the expected namespace is a zero-length string.
The logic for XSDImport does its own check, bypassing SchemaCompiler.processSchemaDocument().
#3 Updated by Michael Kay about 3 years ago
- Status changed from New to Resolved
- Applies to branch 9.9 added
- Fix Committed on Branch 9.9 added
Fixed on the 9.9 branch by removing the condition
&& expected.length() > 0 in
SchemaCompiler.processSchemaDocument(). The rationale for this condition was something to do with chameleon schemas, but it seems xsd:include does not use this path.
I'm not retrofitting the patch to 9.8, for stability reasons. Although code that omits the
namespace attribute in xsl:import-schema is non-conformant, it will currently work and we don't want to break it.
Please register to edit this issue