Re: Inserting nodes

Yes, let's discuss.

Maybe the document/document (top left corner) case should work and replace
the document.

On Wed, Feb 25, 2026 at 5:14 AM Steven Pemberton <steven.pemberton@cwi.nl>
wrote:

> Since this is so badly formatted on the W3C list, here attached is the
> HTML version
>
> Steven
>
> On Wednesday 25 February 2026 14:05:38 (+01:00), Steven Pemberton wrote:
>
> The xpath data model 3.1 says (
> https://www.w3.org/TR/xpath-datamodel-31/#Node)
>
> "There are seven kinds of Nodes in the data model: document, element,
> attribute, text, namespace, processing instruction, and comment."
>
> The possible sub-branches of each of these are:
>
> Document:
> Children: Element, Processing Instruction, Comment, Text.
> Element:
> Children: Element, Processing Instruction, Comment, Text
> Attributes
> Namespaces
> Attribute: -
> Text: -
> Processing instruction:  -
> Comment: -
> Namespace:  -
>
> The text for <insert/> says
> "If [...] there is a node type conflict between the copied node and the
> target location (for example, an attribute cannot be inserted as a sibling
> of an element), the insertion for that copied node is ignored."
>
> So I tried to draw up a table of what happens with each type of node being
> inserted to a location of each type of node. There is an 8th type of node:
> The root element is special because it cannot have sibling elements.
>
> Rows: destination node, Columns: Source node.
> X: Not allowed
> ?: Needs discussion
> Sibling: The node is inserted as a sibling
> Insert/replace: Either insert the node, or replace the node of the same
> name
> Concat: adjacent text nodes must be concatenated
>
> I think it would be good to discuss every entry in this table to make sure
> we agree that that is what happens.
>
> Document Element Attribute Text NS PI Comment
> Document X Replaces root element X X? X Insert? Insert?
> Root element X Replaces root element Insert/replace attribute Sibling?
> Insert/replace Insert Insert
> Element X Sibling unless parent is doc Insert/replace attribute Sibling
> Insert/replace Insert Insert
> Attribute X X Insert/replace attribute X? X X X
> Text X Sibling unless parent is doc X Concat X Sibling Sibling
> NS X X X X Insert/replace X X
> PI X Sibling unless parent is doc X Sibling X Sibling Sibling
> Comment X Sibling unless parent is doc X Sibling X Sibling Sibling
>
>

Received on Sunday, 1 March 2026 14:55:33 UTC