Insert

The insert action inserts items into an instance, and has 5 attributes, all optional:

After successful conclusion, an xforms-insert event is dispatched to the destination instance with appropriate context information, including a list of the items inserted.

An insert action has no effect if:

Each item of the source sequence is inserted:

If an item to be inserted is a node, it and its entire subtree are copied and inserted; if it is an atomic value, a text node is created and inserted.

An item is not inserted:

If the destination location is a root element, the item must be an element, and it replaces the destination element and its children, otherwise the item is not inserted.

If the destination sequence has sort properties, the inserted nodes will end up sorted accordingly, regardless of the at and position attributes.

Document Element Attribute Text NS PI Comment
Document X Replaces root element X X? X? Insert? Insert?
Root element X Replaces root element Becomes/replaces attr Sibling? Insert/replace Insert Insert
Element X Sibling unless parent is doc Becomes/replaces attr Sibling Insert/replace Insert Insert
Attribute X X Replaces or sibling X? X X X
Text X Sibling unless parent is doc X Concat X Sibling Sibling
NS X X X X Sibling or 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

Trying to make the <insert/> element more readable

https://www.w3.org/community/xformsusers/wiki/XForms_2.0#The_insert_Element

The text for the insert element is two pages of fairly opaque text, which I have recently thought about a lot trying to make it more digestible.

=====

The target-sequence is obtained from the element evaluation context.

An origin sequence is obtained by evaluating the origin attribute in the in-scope evaluation context, and removing any root nodes (parents of document elements) from the resulting sequence. An implementation may choose not to include namespace nodes in the origin-sequence, in particular if the namespace axis is not supported or if inserting the namespace node would make the data model inconsistent.

An element is added to a sequence:

===============

The insert action has no effect