W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > July to September 2007

[Bug 5030] Assertions on simple types

From: <bugzilla@wiggum.w3.org>
Date: Mon, 10 Sep 2007 22:56:54 +0000
CC:
To: www-xml-schema-comments@w3.org
Message-Id: <E1IUsBa-0003hN-Lr@wiggum.w3.org>

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

           Summary: Assertions on simple types
           Product: XML Schema
           Version: 1.1 only
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Structures: XSD Part 1
        AssignedTo: cmsmcq@w3.org
        ReportedBy: mike@saxonica.com
         QAContact: www-xml-schema-comments@w3.org


The WG has issued a priority feedback request on the question of whether
assertions should be allowed on simple types.

For the record, I think they should.  Here are some use cases:

(a) consider an attribute (perhaps called xsi:schemaLocation) whose value
consists of a list of URIs, such that the cardinality of the list must be an
even number. There is currently no way to express this constraint.

(b) consider an attribute whose value must be an integer that is a multiple of
10. This can be expressed clumsily using a pattern. But what about an integer
that is a multiple of 20? or 7?

(c) consider a date that must be in the past, or in the future.

(d) consider a date that must not be a Saturday or Sunday

Without assertions on simple types, there is a danger that users will attempt
to define such assertions on some containing complex type, which is not where
they correctly belong; misplacing the constraint in this way will inevitably
lead to maintenance difficulties.

I would propose that for assertions on simple types, the context item should be
the string value of the element or attribute being validated, and the XPath
expression will therefore not have access to any nodes. The examples above
could be achieved with:

(a) test="count(tokenize(., '\s+') mod 2 = 0"

(b) test="number(.) mod 10 = 0"

(c) test="xs:date(.) lt current-date()"

(d) (xs:date(.) - xs:date('1901-01-06')) div xs:dayTimeDuration('PT1D') mod 7)
gt 2
Received on Monday, 10 September 2007 22:56:56 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:50:06 UTC