Bug #6148
closedxsi:type and xsi:schemaLocation on same element
100%
Description
If the xsi:type
and xsi:schemaLocation
attributes are both present on the same element, and if the xsi:type
happens to be processed first, and references a type defined in the schema pointed to by xsi:schemaLocation
, then a failure occurs saying the type is unknown.
Updated by Michael Kay 12 months ago
Putting together a test case for this, I actually managed to get a NullPointerException in XSDImport
when importing a no-namespace schema from one with a namespace which was in turn loaded using xsi:schemaLocation
.
This is achieved by running Validate from the command line with -xsd:test.xsd -s:test.xml -t -xsdversion:1.1 -xsiloc:on
and the following three files in the current directory:
test.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.1">
<xs:element name="foo" type="barType"/>
<xs:simpleType name="barType">
<xs:restriction base="xs:integer">
<xs:minExclusive value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
test2.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tn="foo" targetNamespace="foo" elementFormDefault="qualified">
<xs:import schemaLocation="test.xsd"/>
<xs:complexType name="bazType">
<xs:simpleContent>
<xs:extension base="barType">
<xs:attribute name="code" type="xs:integer"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
test.xml
<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="foo test2.xsd" code="42" xsi:type="foo:bazType" xmlns:foo="foo">23</foo>
Updated by Michael Kay 12 months ago
It's failing trying to output the warning message
"The schema document at " + schemaLocation +
" is not being read because schema components for this namespace are already available"
because namespace
is null. Easily fixed.
Updated by Michael Kay 12 months ago
With this fixed, the test runs successfully (document is valid) if xsi:schemaLocation
precedes xsi:type
, and fails saying Unknown type {foo:bazType} specified in xsi:type attribute
if the order of attributes is reversed. (The parser I'm using appears to deliver attributes in the order they are written).
Updated by Michael Kay 12 months ago
- Status changed from New to Resolved
- Applies to branch 11, 12, trunk added
- Fix Committed on Branch 11, 12, trunk added
- Platforms .NET, Java added
Updated by Debbie Lockett 11 months ago
- % Done changed from 0 to 50
- Fixed in Maintenance Release 11.6 added
Bug fix applied in the Saxon 11.6 maintenance release.
Updated by O'Neil Delpratt 8 months ago
- Status changed from Resolved to Closed
- % Done changed from 50 to 100
- Fixed in Maintenance Release 12.4 added
Bug fix applied in the Saxon 12.4 Maintenance release
Please register to edit this issue