[Bug 4548] [XSLT 2.0] Validation and uniqueness constraints

http://www.w3.org/Bugs/Public/show_bug.cgi?id=4548

           Summary: [XSLT 2.0] Validation and uniqueness constraints
           Product: XPath / XQuery / XSLT
           Version: Recommendation
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLT 2.0
        AssignedTo: mike@saxonica.com
        ReportedBy: mike@saxonica.com
         QAContact: public-qt-comments@w3.org


Bug #4353 addressed the question of validation and XML Schema identity
constraints in both XSLT and XQuery. The issue has been closed with a decision
to change the rules for XQuery; this leaves the corresponding change for XSLT
outstanding, and this bug report is being raised to track the issue. To recap:

Both XSLT and XQuery state that when validating an element node (as distinct
from a document node), identity constraints specified in the element
declaration are not taken into account.

XSLT says: Validation of an element or attribute node only takes into
account constraints on the content of the element or attribute. Validation
rules affecting the document as a whole are not applied. Specifically, this
means... The validation rule "Validation Rule: Identity-constraint
Satisfied" is not applied.

The reasoning given in the spec is spurious. Identity
constraints (xs:unique, xs:key, and xs:keyref) defined on an element
declaration are not document-level constraints, their effect is local to the
element on which they are defined. It would be perfectly possible to apply
such constraints when validating at element level, and it seems odd that we
should diverge from the XML Schema rules in this regard. There might be some
rationale if we ignored everything on the element declaration other than its
type, but we don't: we take into account properties of the element
declaration such as abstract="true", nillability, and fixed values.

The effect of the omission is that it's very easy to output a document which
appears to have been validated, but which will then fail validation if put
through a free-standing schema validator. This is also true of ID/IDREF
constraints, of course, but in this case there is a solid justification, in
that validation of a non-document element would otherwise give spurious
IDREF errors.

In the XSLT case, it's not entirely clear when this rule applies. Does it
apply, for example where validation is initiated using <lre xsl:type="xxx">?

I propose the following change, which is aligned with the decisions made for
XQuery:

In 19.2.1.3, delete the second bullet, which reads: "The validation rule
"Validation Rule: Identity-constraint Satisfied" is not applied."

This leaves text in 19.2.2 saying that identity constraints *are* performed
when validating at document level. This text is now redundant, but I propose to
leave it, as making a change here could easily be misinterpreted.

Received on Tuesday, 8 May 2007 22:04:07 UTC