This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26938 - [XDM31] Constraints on elements
Summary: [XDM31] Constraints on elements
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Data Model 3.1 (show other bugs)
Version: Working drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Norman Walsh
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-30 09:18 UTC by Tim Mills
Modified: 2014-10-14 16:11 UTC (History)
1 user (show)

See Also:


Attachments

Description Tim Mills 2014-09-30 09:18:30 UTC
Unless I'm missing something, the data model doesn'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 "Nodes form a tree." in section 2.1 Terminology.  It can be inferred from "2.4 Document Order" where a total order cannot be defined if a node can be its own parent.

I'd have hoped for a specific constraint in "3 Data Model Construction" but find:

"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."

which seems a little recursive!

Another possible location for making this explicit would be in under "Element Nodes" in "6.2 Element Nodes" 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't prevent a node being its own parent.

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

copy $node := <node />
modify insert node $node into $node
return $node
Comment 1 Jonathan Robie 2014-09-30 12:08:54 UTC
(In reply to Tim Mills from comment #0)
> Unless I'm missing something, the data model doesn'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 "Nodes form a tree." in
> section 2.1 Terminology.  It can be inferred from "2.4 Document Order" where
> 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.

> I'd have hoped for a specific constraint in "3 Data Model Construction" but
> find:
> 
> "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."
> 
> which seems a little recursive!

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

> Another possible location for making this explicit would be in under
> "Element Nodes" in "6.2 Element Nodes" 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't prevent a node being its own parent.
> 
> This has a bearing on the result of the XQuery Update expression
> 
> copy $node := <node />
> modify insert node $node into $node
> return $node

That's well specified in the XQuery Update Facility, using the current XDM.
Comment 2 Tim Mills 2014-09-30 12:19:58 UTC
> That's well specified in the XQuery Update Facility, using the current XDM.

Agreed.  I hadn'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 "6.2 Element Nodes" that the data model constrains the parent-child relationship to a tree.
Comment 3 Tim Mills 2014-10-14 16:10:48 UTC
The WG discussed this in the teleconference on 2014-10-14 and agreed to add such a constraint.