<?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>5480</bug_id>
          
          <creation_ts>2008-02-14 12:19:34 +0000</creation_ts>
          <short_desc>[FS] Substitution groups and 8.2.3.1.1</short_desc>
          <delta_ts>2009-06-22 20:48:46 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Formal Semantics 1.0</component>
          <version>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>LATER</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>fix in 1.1</status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nick Jones">nick</reporter>
          <assigned_to name="Michael Dyck">jmdyck</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>19043</commentid>
    <comment_count>0</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2008-02-14 12:19:34 +0000</bug_when>
    <thetext>Consider a schema:

&lt;schema targetNamespace=&quot;http://www.w3.org/XQueryTest/testcases&quot; xmlns:tc=&quot;http://www.w3.org/XQueryTest/testcases&quot;&gt;
  &lt;element name=&quot;root&quot;&gt;
    &lt;complexType&gt;
      &lt;sequence&gt;
        &lt;element ref=&quot;tc:schema-element-head&quot;/&gt;
      &lt;/sequence&gt;
    &lt;/complexType&gt;
  &lt;/element&gt;
  &lt;element name=&quot;schema-element-head&quot; type=&quot;string&quot;/&gt;
  &lt;element name=&quot;schema-element-group&quot; type=&quot;string&quot; substitutionGroup=&quot;tc:schema-element-head&quot;/&gt;
&lt;/schema&gt;

And $input-context bound to the document:

&lt;tc:root xmlns:tc=&quot;http://www.w3.org/XQueryTest/testcases&quot;&gt;
  &lt;tc:schema-element-group&gt;string&lt;/tc:schema-element-group&gt;
&lt;/tc:root&gt;

And the query

import schema namespace tc=&quot;http://www.w3.org/XQUeryTest/testcases&quot;;
declare variable $input-context1 as document-node(schema-element(tc:root)) external;
$input-context/tc:root/tc:schema-element-group

Clearly the expected result should be the schema-element-group element, but I think the typing rules give the type of the axis expression as empty-sequence.

$input-context has type: document ( element tc:root of Type )
where Type is element tc:element-schema-head of xsd:string

Firstly I don&apos;t no believe any of the judgements (particularly the with union interpretation judgement) cause tc:element-schema-group to be included in Type

Hence we ended up wanting to make the judgement from 8.2.3.1.1

statEnv |- test tc:schema-element-group with element of element tc:schema-element-head of xsd:string : element tc:schema-element-group of xsd:string

In the recommendation I don&apos;t think this case is caught, as clearly the QNames schema-element-group and schema-element-head don&apos;t match. But I don&apos;t think it is caught by the &quot;Lastly, if none of the above rules holds, then the type of the input expression is empty.&quot; as the line:

statEnv |-  not(element ElementNameOrWildcard 1 TypeSpecifier1 &lt;: element ElementNameOrWildcard 2 TypeSpecifier2)

is false as I believe

element tc:schema-element-group &lt;: element tc:schema-element-head

is true, as subtyping (&lt;:) is true if every value which &quot;matches&quot; the first type also &quot;matches&quot; the second, and the &quot;matches&quot; judgement uses judgements &quot;name lookup&quot; and hence &quot;substitutes for&quot;.

I think this problem was noted in #4261, and fixed in the erratum. And I now agree the final empty-sequence case covers what is not covered in the prior cases, particularly with rule 13, but I&apos;m am unsure if it is fixed in the correct way, as now it would cause the above query to statically type to the empty-sequence. Should the change not be one using subtyping rather than name matching for the prior static judgements?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>19054</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-02-14 18:21:43 +0000</bug_when>
    <thetext>The Product/Component of this issue is &quot;XML Query Test Suite&quot;. Did you mean to raise it against the Formal Semantics?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>19067</commentid>
    <comment_count>2</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2008-02-14 22:56:53 +0000</bug_when>
    <thetext>Sorry. Yes, it should be formal semantics. Will change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21086</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-07-07 23:36:57 +0000</bug_when>
    <thetext>(In reply to comment #0)

&gt; $input-context has type: document ( element tc:root of Type )
&gt; where Type is element tc:element-schema-head of xsd:string

That&apos;s not what I get. 

FS 5.14 Variable Declaration / Static Context Processing / rule 3
tells us that the type of $input-context is
    [[ document-node(schema-element(tc:root)) ]]_sequencetype

FS 3.5.4 SequenceType Matching / Normalization / rule 19 maps that to:
    document { [[ schema-element(tc:root) ]]_sequencetype &amp; (pi|comment)* }

which rule 11 maps to:
    document { element tc:root &amp; (pi|comment)* }

----

Moreover, when I try to work through the (normalization and) static analysis of
    $input-context/tc:root/tc:schema-element-group
I don&apos;t get as far as you -- I can&apos;t figure out the Definition that would be put in elemDecl for &lt;element name=&quot;root&quot;&gt;...&lt;/element&gt;. I can see that
D.4.1 Global element declarations / Schema mapping / rule 2
maps it to
    define element tc:root [[ &lt;complexType&gt;...&lt;/complexType&gt; ]]_content(tc)
and
D.5.2 Local complex type / Schema mapping / rule 1
maps that to
    define element tc:root [[ &lt;sequence&gt;...&lt;/sequence&gt; ]]_mixed_content(tc)
but I don&apos;t get any farther than that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21091</commentid>
    <comment_count>4</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2008-07-08 13:20:02 +0000</bug_when>
    <thetext>I agree with your first point, but I think the (pi|comment)* will soon disappear when we start applying the axis tests.

As for the rest of the expansion of element tc:root.

I think D.9.3 will expand the &lt;sequence&gt; element for us:

define element tc:root [ (&lt;element ref=&quot;tc:schema-element-head&quot;/&gt;) ]_mixed_content(tc)

Then D.4.2 will handle the &lt;element ref=&quot;tc:schema-element-head&quot;/&gt;:

define element tc:root [ (element tc:schema-element-head) ]_mixed_content(tc)

which will then be defined by D.4.1:

define element tc:root [ (element tc:schema-element-head of type xsd:string) ]_mixed_context(tc)

Or have I misunderstood something?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21093</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-07-08 20:15:20 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; 
&gt; As for the rest of the expansion of element tc:root.
&gt; 
&gt; I think D.9.3 will expand the &lt;sequence&gt; element for us:

D.9.3 (sub-)defines the []_content mapping, not the []_mixed_content mapping.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21119</commentid>
    <comment_count>6</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2008-07-10 10:04:48 +0000</bug_when>
    <thetext>OK. Presumably we should be have some rules to work out a type for &lt;complexType&gt;&lt;sequence&gt;...&lt;/sequence&gt;&lt;/complexType&gt; though?

Can the current D.9.3 rule ever be hit? I think we can only get a &lt;sequence&gt; within a &lt;complexType&gt;, so should the content type mapping match? i.e. be _mixed_content instead of _content.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24093</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-03-07 07:09:05 +0000</bug_when>
    <thetext>I believe this issue gets into problems with Appendix D that would be
difficult to fix within the timeframe of FS 1.0. Therefore, I am marking
the issue as resolved-LATER, and hope to fix it in FS 1.1.

If you accept this resolution, please mark the issue CLOSED.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25662</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2009-06-22 20:48:46 +0000</bug_when>
    <thetext>After 3 months with no response from the original reporter,
I am marking this issue CLOSED.  Feel free to reopen it
if you disagree with this outcome.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>