Bug #1998
closedSpurious warning about optional field in xs:key
100%
Description
From the saxon-help list:
The problem that I am having is that I cannot determine if Saxon is giving me a spurious warning or whether there is actually something wrong with my schema. Here's a stripped down version of the schema that exhibits the problem:
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:items="file://localhost/items"
version="1.1"
elementFormDefault="qualified"
targetNamespace="file://localhost/items">
<xs:complexType name="item" final="#all">
<xs:attribute name="id" type="xs:string" use="required"/>
<xs:attribute name="index" type="xs:positiveInteger" default="1"/>
</xs:complexType>
<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element
name="item"
type="items:item"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:key name="item-id">
<xs:selector xpath="items:item"/>
<xs:field xpath="@id"/>
<xs:field xpath="@index"/>
</xs:key>
</xs:element>
</xs:schema>
and here is a sample instance document:
<items
xmlns="file://localhost/items"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="file://localhost/items items.xsd">
<item id="A"/>
Saxon keeps issuing this warning:
Warning: on line 27 of items.xsd:
The field expression may select no nodes, which would make the instance document invalid
Which I assume has something to do with the use of the index attribute which is non-required and has a default value. I have tried all sorts of ways to try to make an invalid instance document, but all that happens is this warning.
Is something wrong with what I am doing? Is it just a Saxon quirk?
Regards,
Paul Mensonides
Please register to edit this issue