<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>5030</bug_id>
          
          <creation_ts>2007-09-10 22:56:54 +0000</creation_ts>
          <short_desc>Assertions on simple types</short_desc>
          <delta_ts>2008-05-31 07:50:53 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XML Schema</product>
          <component>Structures: XSD Part 1</component>
          <version>1.1 only</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>XPath cluster</status_whiteboard>
          <keywords>resolved</keywords>
          <priority>P1</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="C. M. Sperberg-McQueen">cmsmcq</assigned_to>
          
          
          <qa_contact name="XML Schema comments list">www-xml-schema-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>16447</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2007-09-10 22:56:54 +0000</bug_when>
    <thetext>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=&quot;count(tokenize(., &apos;\s+&apos;) mod 2 = 0&quot;

(b) test=&quot;number(.) mod 10 = 0&quot;

(c) test=&quot;xs:date(.) lt current-date()&quot;

(d) (xs:date(.) - xs:date(&apos;1901-01-06&apos;)) div xs:dayTimeDuration(&apos;PT1D&apos;) mod 7) gt 2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18489</commentid>
    <comment_count>1</comment_count>
    <who name="David Ezell">David_E3</who>
    <bug_when>2008-01-23 21:21:18 +0000</bug_when>
    <thetext>Phase I agreement:
1 yes, assertions on simple types
2 do not change the existing built-ins-only rule (n.b. this also prevents circularity)
3 appears as new property of simple types (not as new facet)
4 context item is string value of the item, as xs:untypedAtomic
(alternatives: string value as xs:string, or string value as the appropriate primitive (anySimpleType for lists or unions), or string value as anySimpleType)
5 Assertions legal on restriction and on list and on union (i.e. any simple type constructor).  (Alternative:  on restriction only.) 

The WG discussed that another alternative for point 4 would be to use the base type, both for atomics and for lists, i.e. if I&apos;m asserting something of a list of my:specialDate, take it into XPath as a list of xs:date.  MKay said IIRC the context item cannot be a list.  

Ref: M. Kay&apos;s note http://lists.w3.org/Archives/Member/w3c-xml-schema-ig/2008Jan/0013.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>20297</commentid>
    <comment_count>2</comment_count>
    <who name="C. M. Sperberg-McQueen">cmsmcq</who>
    <bug_when>2008-05-29 06:44:50 +0000</bug_when>
    <thetext>A wording proposal intended to resolve this issue is at

  http://www.w3.org/XML/Group/2004/06/xmlschema-1/structures.b5030.html
  http://www.w3.org/XML/Group/2004/06/xmlschema-2/datatypes.b5030.html
  (member-only links)

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>20346</commentid>
    <comment_count>3</comment_count>
    <who name="C. M. Sperberg-McQueen">cmsmcq</who>
    <bug_when>2008-05-31 02:56:56 +0000</bug_when>
    <thetext>The proposal mentioned in comment #2 was adopted by the WG at today&apos;s call.

Michael, if you would please do the honors?  If we don&apos;t hear from you
in the next two weeks, we will be forced to assume that you approve
of the adoption of your proposal.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>