<?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>26938</bug_id>
          
          <creation_ts>2014-09-30 09:18:30 +0000</creation_ts>
          <short_desc>[XDM31] Constraints on elements</short_desc>
          <delta_ts>2014-10-14 16:11:05 +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>Data Model 3.1</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</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="Tim Mills">tim</reporter>
          <assigned_to name="Norman Walsh">ndw</assigned_to>
          <cc>jonathan.robie</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>112449</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2014-09-30 09:18:30 +0000</bug_when>
    <thetext>Unless I&apos;m missing something, the data model doesn&apos;t seem to constrain an element not to be a parent of itself explicitly.

There are some hints that this is the case, such as &quot;Nodes form a tree.&quot; in section 2.1 Terminology.  It can be inferred from &quot;2.4 Document Order&quot; where a total order cannot be defined if a node can be its own parent.

I&apos;d have hoped for a specific constraint in &quot;3 Data Model Construction&quot; but find:

&quot;There are no constraints on how an instance of the data model may be constructed directly, save that the resulting instance must satisfy all of the constraints described in this document.&quot;

which seems a little recursive!

Another possible location for making this explicit would be in under &quot;Element Nodes&quot; in &quot;6.2 Element Nodes&quot; which currently reads:

* If a node N is among the children of an element E, then the parent of N must be E.
* ... if a node N has a parent element E, then N must be among the children of E.

but this doesn&apos;t prevent a node being its own parent.

This has a bearing on the result of the XQuery Update expression

copy $node := &lt;node /&gt;
modify insert node $node into $node
return $node</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112457</commentid>
    <comment_count>1</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2014-09-30 12:08:54 +0000</bug_when>
    <thetext>(In reply to Tim Mills from comment #0)
&gt; Unless I&apos;m missing something, the data model doesn&apos;t seem to constrain an
&gt; element not to be a parent of itself explicitly.
&gt; 
&gt; There are some hints that this is the case, such as &quot;Nodes form a tree.&quot; in
&gt; section 2.1 Terminology.  It can be inferred from &quot;2.4 Document Order&quot; where
&gt; a total order cannot be defined if a node can be its own parent.

I do believe that these statements give you what you need.

&gt; I&apos;d have hoped for a specific constraint in &quot;3 Data Model Construction&quot; but
&gt; find:
&gt; 
&gt; &quot;There are no constraints on how an instance of the data model may be
&gt; constructed directly, save that the resulting instance must satisfy all of
&gt; the constraints described in this document.&quot;
&gt; 
&gt; which seems a little recursive!

XQuery and XPath each have their own sections on consistency constraints, which add further requirements. I don&apos;t think we should move these to XDM, that would be a drastic restructuring of our work at this late stage.

&gt; Another possible location for making this explicit would be in under
&gt; &quot;Element Nodes&quot; in &quot;6.2 Element Nodes&quot; which currently reads:
&gt; 
&gt; * If a node N is among the children of an element E, then the parent of N
&gt; must be E.
&gt; * ... if a node N has a parent element E, then N must be among the children
&gt; of E.
&gt; 
&gt; but this doesn&apos;t prevent a node being its own parent.
&gt; 
&gt; This has a bearing on the result of the XQuery Update expression
&gt; 
&gt; copy $node := &lt;node /&gt;
&gt; modify insert node $node into $node
&gt; return $node

That&apos;s well specified in the XQuery Update Facility, using the current XDM.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112460</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2014-09-30 12:19:58 +0000</bug_when>
    <thetext>&gt; That&apos;s well specified in the XQuery Update Facility, using the current XDM.

Agreed.  I hadn&apos;t spotted that this expression causes the inserted nodes to be copied.

However, I believe that the document would be improved by stating explicitly in &quot;6.2 Element Nodes&quot; that the data model constrains the parent-child relationship to a tree.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113116</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2014-10-14 16:10:48 +0000</bug_when>
    <thetext>The WG discussed this in the teleconference on 2014-10-14 and agreed to add such a constraint.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>