<?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>1250</bug_id>
          
          <creation_ts>2005-04-14 18:50:48 +0000</creation_ts>
          <short_desc>[XQuery] the typed value of a document node</short_desc>
          <delta_ts>2005-05-05 16:28:35 +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>XQuery 1.0</component>
          <version>Last Call drafts</version>
          <rep_platform>All</rep_platform>
          <op_sys>Windows 2000</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></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="Henry Luo">henryluo</reporter>
          <assigned_to name="Don Chamberlin">chamberl</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>3748</commentid>
    <comment_count>0</comment_count>
    <who name="Henry Luo">henryluo</who>
    <bug_when>2005-04-14 18:50:48 +0000</bug_when>
    <thetext>Under section 2.5.2 Typed Value and String Value
It is specified that For document nodes, the typed value of the node is the same
as its string value, which is the concatenating the string values of all its
descendant text nodes, in document order.

However, it might be more natural for the typed value for a document node to be
the same as the type value of the root element.
Since XML document can only one root element. That element contains all the
information that the document can have (except some comments).

In that way, the typed value of a document node still preserve the sequence of
atomic values. 

And when the user needs the concatenated string version, they can always use the
string value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3749</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Rys">mrys</who>
    <bug_when>2005-04-14 18:55:02 +0000</bug_when>
    <thetext>
The following is my personal answer, based on the history of the current 
behaviour:

First, an XQuery document node can contain more than a single element node, 
and not every element node has a typed value. Thus it is better to keep the 
definition as is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3750</commentid>
    <comment_count>2</comment_count>
    <who name="Henry Luo">henryluo</who>
    <bug_when>2005-04-14 19:55:39 +0000</bug_when>
    <thetext>However, your answer has lead to another issue: 
 
Does the two XQuery expressions
 
fn:doc($uri as xs:string?) as document-node()?
document { expr }
 
return the same type of document node? 
If yes, then they should have same typed-value. 
If fn:doc returns a node tree, then should document { expr } also be typed as 
node tree?
 
And keeping document { expr } as node tree instead of string, 
has the benefit to enable the result document to be assigned to an variable,
and further processed by XQuery expressions like fn:doc.
 
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3751</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2005-04-14 20:12:11 +0000</bug_when>
    <thetext>The reason for the rule you refer to is backwards compatibility with XSLT 1.0.
Here it is very common for users to use constructs such as

&lt;xsl:variable name=&quot;x&quot;&gt;
[&lt;xsl:value-of select=&quot;d&quot;/&gt;]
&lt;/xsl:variable&gt;

and then use $x as if it were a string.

Here the value of $x is a document node, which has a single text node child.
There is no root element. It&apos;s also common to see constructs like

&lt;xsl:variable name=&quot;lookup&quot;&gt;
&lt;a code=&quot;12&quot; value=&quot;red&quot;/&gt;
&lt;a code=&quot;13&quot; value=&quot;blue&quot;/&gt;
&lt;a code=&quot;14&quot; value=&quot;green&quot;/&gt;
&lt;/xsl:variable&gt;

where the document has several element nodes among its children.

Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3753</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2005-04-14 20:30:01 +0000</bug_when>
    <thetext>Responding to this question:

&gt;Does the two XQuery expressions
 
&gt;fn:doc($uri as xs:string?) as document-node()?
&gt;document { expr }
 
&gt;return the same type of document node? 

Yes, both expressions return a document node and the operations available on the
resulting document nodes are identical. In both cases, for example, you can use
a path expression $d//* to find all the element nodes within the document, and
in both cases you can use string($d) to get the string-value of the document
node, that is, the concatenation of its contained text nodes.

Michael Kay
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3758</commentid>
    <comment_count>5</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2005-04-18 15:55:40 +0000</bug_when>
    <thetext>Henry Luo, will you please indicate whether you are satisfied with the 
explanation provided by Michael Kay, or whether you are calling for a change to 
the XQuery specification?
Thanks,
Don Chamberlin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3774</commentid>
    <comment_count>6</comment_count>
    <who name="Henry Luo">henryluo</who>
    <bug_when>2005-04-20 08:05:59 +0000</bug_when>
    <thetext>I&apos;d like to rephrase here, and correct me if I&apos;m wrong:
1. Schema type or data model for fn:doc or document {} are preserved as node 
tree, which is also used for path expression evaluation.
2. Typed value or atomized value is used, according to spec 2.4.2, for Function 
calls and returns. Does that mean when a $doc is passed into a function, it 
becomes concatenated string value? If that&apos;s the case, the node tree structure 
is lost, and what&apos;s the use of it in the function?

So i think, either the document should not be atomized when passed to a 
function and preserved as a complex type, or the typed value of document or 
complex typed element should be defined. 

Otherwise, how can a function receive a node tree as parameter, instead of just 
a sequence of atomic values?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3779</commentid>
    <comment_count>7</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2005-04-20 16:31:52 +0000</bug_when>
    <thetext>Type-conversion of function arguments is governed by the expected type of the 
argument (that is, the type that was declared for the argument in the function 
signature). If the expected type is an atomic type, then atomization is 
performed when the function is called. If the expected type is a complex type, 
then no atomization is performed. Therefore, when a document node is passed to 
a function, it may or may not be atomized, depending on how the argument was 
declared in the function signature. These rules are explained in XQuery Section 
3.1.5, &quot;Function Calls&quot;.

Henry, will you please let us know whether this explanation resolves your issue?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3528</commentid>
    <comment_count>8</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2005-05-04 23:27:56 +0000</bug_when>
    <thetext>Henry,
I believe that the questions raised by this comment have been answered and the 
comment can be closed. If you disagree, please reply before May 11, 2005.
Thanks,
--Don Chamberlin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3536</commentid>
    <comment_count>9</comment_count>
    <who name="Henry Luo">henryluo</who>
    <bug_when>2005-05-05 01:39:51 +0000</bug_when>
    <thetext>Yes. I have no problem to close this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3540</commentid>
    <comment_count>10</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2005-05-05 16:28:19 +0000</bug_when>
    <thetext>Thanks, Henry!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>