Project

Profile

Help

Bug #1998

closed

Spurious warning about optional field in xs:key

Added by Michael Kay about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2014-02-06
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

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

Actions #1

Updated by Michael Kay about 10 years ago

  • Status changed from New to In Progress

The spec in this area is pretty ropey (as is often the case with XSD). It says in 3.11.4 rule 1 "A data model instance is constructed from the input information set, as described in [XDM]. ", but it doesn't say which part of XDM it is referring to: is it construction from an Infoset, or construction from a PSVI? The fact that it says "input information set" suggests the former, as does the fact that this operation is part of validation, so the PSVI doesn't yet exist. If it really were from the infoset, then default values for attributes would not be present. But the spec goes on to say that it uses the [schema actual value] of the nodes, which is a concept that doesn't even exist in XDM! And in the Note, it confirms that default values "may" be used, which I guess one should read as meaning that they must be used if they are present. At any rate, Saxon does use the default value when it actually evaluates the constraint, so the static validation of the schema that produces this warning should take this into account, and not produce the warning if there is a default or fixed value.

Actions #2

Updated by Michael Kay about 10 years ago

  • Status changed from In Progress to Resolved

A patch has been committed on the 9.5 and 9.6 branches.

Actions #3

Updated by O'Neil Delpratt about 10 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to 9.5.1.5

Bug fix applied in Saxon maintenance release 9.5.1.5

Please register to edit this issue

Also available in: Atom PDF