<?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>13028</bug_id>
          
          <creation_ts>2011-06-23 13:04:38 +0000</creation_ts>
          <short_desc>[XQUF] Error in static typing rules for replace node Expr1 with Expr2</short_desc>
          <delta_ts>2011-06-23 16:20:10 +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>Update Facility</component>
          <version>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc>http://www.w3.org/TR/xquery-update-10/#id-update-typing-replace</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Mills">tim</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>jmdyck</cc>
          
          <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>50156</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2011-06-23 13:04:38 +0000</bug_when>
    <thetext>Section 2.4.3.2 Replacing the Value of a Node states:

&quot;The expression following the keyword with must be a simple expression; otherwise a static error is raised [err:XUST0001]. This expression is evaluated as though it were an enclosed expression in an element constructor (see Rule 1e in Section 3.7.1.3 ContentXQ). Let $rlist be the node sequence that results from this evaluation. If $rlist contains a document node, the document node is replaced in $rlist by its children.&quot;

However, in section 4.5.3 Replace, the text states

&quot;An element, text, comment, or processing instruction node can be replaced only by zero or more element, text, comment, or processing instruction nodes.&quot;

statEnv  |- Expr1 : Type1
statEnv |- Type1 &lt;: (element * | text | comment | processing-instruction *)?
statEnv  |- Expr2 : Type2
statEnv |- Type2 &lt;: (element * | text | comment | processing-instruction *)*
-----------------------------------------------------------------------------
statEnv  |- replace node Expr1 with Expr2 : empty

This rule should instead be:

statEnv  |- Expr1 : Type1
statEnv |- Type1 &lt;: (element * | text | comment | processing-instruction *)?
statEnv  |- Expr2 : Type2
statEnv |- Type2 &lt;: (document | element * | text | comment | processing-instruction *)*
-----------------------------------------------------------------------------
statEnv  |- replace node Expr1 with Expr2 : empty

because Expr2 may evaluate to a sequence including document nodes, but these document nodes are replaced by their children.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50157</commentid>
    <comment_count>1</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2011-06-23 13:17:44 +0000</bug_when>
    <thetext>On a related note, the specification states that XUDY0027 is raised if the result of evaluating the target expression is an empty sequence.

Why is this not a type error, and why do the static typing rules not prevent it?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50163</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2011-06-23 15:41:45 +0000</bug_when>
    <thetext>Re your original point: No, the call to fs:item-sequence-to-node-sequence() introduced in the normalization rule ensures that the *core* replace expression (which is the one to which the static typing rules pertain) doesn&apos;t have to deal with document nodes.

(The static type of the *argument* to fs:item-sequence-to-node-sequence() might involve the document node type. It also might involve atomic types. Those possibilities are handled by the static typing rules for that function.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50164</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2011-06-23 15:45:56 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; Re your original point: No, the call to fs:item-sequence-to-node-sequence()
&gt; introduced in the normalization rule ensures that the *core* replace expression
&gt; (which is the one to which the static typing rules pertain) doesn&apos;t have to
&gt; deal with document nodes.
&gt; 
&gt; (The static type of the *argument* to fs:item-sequence-to-node-sequence() might
&gt; involve the document node type. It also might involve atomic types. Those
&gt; possibilities are handled by the static typing rules for that function.)

Ah, of course - thanks.

I&apos;d still like Comment #1 to be considered by the WG.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50165</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2011-06-23 16:08:02 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; On a related note, the specification states that XUDY0027 is raised if the
&gt; result of evaluating the target expression is an empty sequence.
&gt; 
&gt; Why is this not a type error, and why do the static typing rules not prevent
&gt; it?

Well, the static typing rules allow it because it&apos;s not a type error.

As to why it&apos;s not a type error... this question was raised in the WG about a year ago:
http://lists.w3.org/Archives/Member/w3c-xsl-query/2010Apr/0108.html (member-only)
It didn&apos;t get a definitive answer, but one person&apos;s recollection was that making it a type error would have been unusable under static typing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50166</commentid>
    <comment_count>5</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2011-06-23 16:19:59 +0000</bug_when>
    <thetext>Thanks.  I&apos;m happy to close the report as INVALID.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>