<?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>3673</bug_id>
          
          <creation_ts>2006-09-08 04:09:24 +0000</creation_ts>
          <short_desc>revisit (and enlarge) XPath subset for assertions?</short_desc>
          <delta_ts>2007-05-02 00:11:54 +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>Macintosh</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>important, hard</status_whiteboard>
          <keywords>needsDrafting</keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="C. M. Sperberg-McQueen">cmsmcq</reporter>
          <assigned_to name="C. M. Sperberg-McQueen">cmsmcq</assigned_to>
          <cc>sandygao</cc>
          
          <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>11504</commentid>
    <comment_count>0</comment_count>
    <who name="C. M. Sperberg-McQueen">cmsmcq</who>
    <bug_when>2006-09-08 04:09:24 +0000</bug_when>
    <thetext>Thinking about some of our use cases for check clauses the other day,
I became slightly more concerned than I had been by the restrictions
placed on the XPath expressions of assertions in our current working
draft.

The use cases provide the following examples of XPath expressions for
&apos;high priority&apos; use cases.  Those marked * are not legal according to
the grammar in our most recent public working draft.  Some variations
on them, which do not appear in the wiki, some of which are intended
to have the same semantics when used as assertions and some of which
are intended to illustrate syntactic limits on the existing grammar,
are also given, marked + (or +* if they are not accepted by the
grammar).

It&apos;s possible that my parser is faulty, so first of all I ask those
interested to see if they agree with me about which of these XPath
expressions are accepted, and which are not accepted, by our current
XPath subset.

  Value-equals test required (1)

  *  @type=&apos;BridgeEthernet&apos; &amp; @BrEthernetIP = &apos;&apos; 
  +* @type=&apos;BridgeEthernet&apos; and @BrEthernetIP = &apos;&apos; 
  +* @type eq &apos;BridgeEthernet&apos; and @BrEthernetIP eq &apos;&apos; 
  +  @type eq xsd:string(&apos;BridgeEthernet&apos;) and @BrEthernetIP eq xsd:string(&apos;&apos;) 

  * ./@type=&apos;BridgedEthernet&apos;
  + ./@type eq xsd:string(&apos;BridgedEthernet&apos;)

  * ./@type=&apos;BridgedEthernet&apos; and not ./@BrEthernetIP
  +* ./@type eq xsd:string(&apos;BridgedEthernet&apos;) and not ./@BrEthernetIP
  +* ./@type eq xsd:string(&apos;BridgedEthernet&apos;) and not(./@BrEthernetIP)
  +  ./@type eq xsd:string(&apos;BridgedEthernet&apos;) and ./@BrEthernetIP


  Value arithmetic required - attributes (2)

  *  @min &lt;= @max
  +  @min le @max

  *  . &lt; ../@min
  *  . le ../@min

  *  @max &gt;= @min
  +  @max ge @min


  Constraints on grandchildren (5)

  Simple attribute implication (6)
  *  ./@attrOne or not(./@attrTwo)
  *  ./@attrOne or not ./@attrTwo
  +  ./@attrOne or ./@attrTwo

    ./@attrOne

  *  not(./@attrOne)

  *  ./@attrTwo and not(@attrOne)

  Attribute mutex (7)
  *  (./@dec or ./@hex) and not(./@dec and ./@hex)
  +* (./@dec or ./@hex) and (./@dec and ./@hex)
  +* (./@dec or ./@hex)
  +  ./@dec or ./@hex

     ./@dec and ./@hex
  +* (./@dec and ./@hex)

  *  not(./@dec) and not(./@hex)

  Open content, sort of (9)

  Value arithmetic required - elements (12)
  *  (./a + ./b + ./c) &lt;= 30
  +* (./a + ./b + ./c) le 30
  +* ./a &lt;= 30
  +* ./a le 30
  +* ./a le xsd:int(30)
  + ./a le xsd:int(&apos;30&apos;)

  * ./a + ./b + ./c &gt; 30.00


  Require somewhere (20)
  *  count(//buyer) &gt; 0
  +* count(//buyer) gt 0
  +* count(//buyer) gt xsd:int(&apos;0&apos;)
  +* count(//buyer)

  *  count(//buyer-id | //buyer/@id) &amp;gt; 0
  *  count(//seller) &amp;gt; 0
  *  count(//seller-id | //seller/@id) &amp;gt; 0
  *  count(//binding-jurisdiction) = 1
  *  count(//severability | //nonseverability) = 1
  *  count(//start-date) = 1 and count(//end-date) = 1

  Deep inclusions (23)
  *  not(ancestor::html:form)
  *  not(.//html:input[not(./ancestor::html:form])
  *  count(.//html:input[ancestor::html:form])
                = count(.//html:input)
  *  count(.//html:form//html:input)
                = count(.//html:input)


I think the bottom line is (a) either the grammar or my parser is
having some trouble with not() and count(), and (b) that if my parser
is correct then our subset is too small, because it makes it too hard
to write useful assertions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>11534</commentid>
    <comment_count>1</comment_count>
    <who name="Sandy Gao">sandygao</who>
    <bug_when>2006-09-08 20:53:29 +0000</bug_when>
    <thetext>I was also thinking about expanding the subset. My focus has been:
- Allow &quot;quantified&quot; expression (some/every ... satisfies ...) and possibly &quot;if&quot; expressions (if ... then ... else ...) (it&apos;s unfortunate there isn&apos;t a short form like if ... then ...)
- Allow more than attributes in predicates (hoping that it&apos;s still streamable)

Now how are you suggesting we expand it?
- not/count: in XPath 2.0, I think they became fn:not and fn:count, which are allowed by the grammar. Hum... not sure whether it still allows XPath 1.0 functions without the namespace.
- About casting: I think maybe it&apos;s OK to omit xs:string(). Treat it as the default. We can also treat integer literals in the same way. Or we can go to the extreme and omit all constructor functions and implicitly cast the string value to the value space of the other operand.
- Comparison: I think we have to use the 2-letter operators to match XPath 2.0 semantics
- About arithmatic and promotion/casting: this is the discussion we had and I&apos;m inclined to say &quot;no&quot; for now.

Also note that for &quot;Require somewhere&quot;, we only allow &quot;.//buyer&quot; and not &quot;//buyer&quot;. To make sure &quot;buyer&quot; appears somewhere in the tree, you only need
.//buyer
which is equivalent to
fn:count(.//buyer) &gt; xs:int(&apos;0&apos;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12108</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2006-09-27 18:00:24 +0000</bug_when>
    <thetext>Here are some other things which I would like to say, but can&apos;t:

(1) events must be in chronological order

every $x in event, $y in event satisfies if $y &gt;&gt; $x then $y/date &gt;= $x/date

(2) currency must be one of the currencies in http://example.com/currencies

. = doc(http://example.com/currencies)/currencies/currency

(3) events must not be in the future

date &lt;= current-date()

(4) date must not be a Sunday

(5) height must be a multiple of 0.25

I&apos;m even finding it difficult to write basic co-occurrence tests such as

if (@a &gt; 0) then exists(@b)

I think there are workarounds for most of these within the proposed subset, but some of them are unnecessarily tortuous, for example

not(@a gt 0 and not(@b))

The restrictions are so arbitrary that it&apos;s going to be very hard for users to remember them, let alone to learn how to work around them.

Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14059</commentid>
    <comment_count>3</comment_count>
    <who name="C. M. Sperberg-McQueen">cmsmcq</who>
    <bug_when>2007-02-22 20:21:37 +0000</bug_when>
    <thetext>An update on current status.  At the ftf meeting at the end of
October and beginning of November, the WG agreed that in principle
a legal schema can use any legal XPath 2.0 expression as an
assertion.  

To avoid requiring all XSD processors to implement all of
XPath 2.0, the subset defined in the spec will be retained, 
and all schema processors are required to support at least 
that subset of XPath 2.0; other processors may choose to 
support more, or all, of XPath 2.0.  Schema authors who care
more about power than interoperability will choose schema
processors accordingly; schema authors who care about
interoperability more than about power will restrict themselves
to expressions in the subset.  (Schema authors who care about
both power and interoperability will presumably just curse
the Working Group.) 

So a technical direction for resolution of this issue
has been set, although no final wording has been adopted
(and thus the decision is not yet part of the status quo
text).  A wording proposal is expected to go to the Working
Group real soon now, possibly today or tomorrow.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14548</commentid>
    <comment_count>4</comment_count>
    <who name="C. M. Sperberg-McQueen">cmsmcq</who>
    <bug_when>2007-03-27 15:00:49 +0000</bug_when>
    <thetext>The wording proposal mentioned in comment 3 has been discussed at length by
the Working Group and most of it was adopted in the WG call of 23 March 2007.

The part not adopted dealt with the typing of the data model instance;
see bug 4416.

The part adopted makes clear that the XPath subset is not a restriction on the
XPath expressions contained in a legal schema, but an implementation minimum.
Accordingly, I&apos;m marking this issue closed.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14963</commentid>
    <comment_count>5</comment_count>
    <who name="C. M. Sperberg-McQueen">cmsmcq</who>
    <bug_when>2007-05-02 00:11:54 +0000</bug_when>
    <thetext>As the originator of this issue, I assent to the WG&apos;s resolution of the
question and accordingly close the bug report.  I note in passing
that some other readers of the XML Schema 1.1 spec are still unhappy 
with the definition of the XPath subset as an implementation minimum,
but I will leave it to those readers to make their views heard.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>