XForms 2.0 insert: where does an item go when a multi-step ref selects nothing?

Hello,

I would like to check my reading of one clause of The insert Element, and ask whether a note or a change would be welcome.

The clause says that each item of the source sequence is inserted:


  *   next to the destination location, if the destination sequence is non-empty,
  *   into the context node otherwise, ignoring at and position.

Take this instance, with the action in the context of data:

<data>
  <list/>
  <blank><a>0</a></blank>
</data>

<insert ref="list/a" origin="blank/a"/>

While list holds at least one a, the new a goes next to the last one, inside list. When list is empty, the destination sequence is empty, and by the literal clause the new a goes into the context node, which is data. The result is <data><list/><blank>…</blank><a>0</a></data>, beside list rather than inside it.

So the same action puts an item in two different places depending only on whether the list is currently empty. Authors read ref="list/a" as "an a in list", and authoring tools generate exactly this form for a repeating section. In my experience it is the first click on "Add" in an empty table that goes wrong, and when a schema is attached the result is usually invalid.

I know the specification's own example handles the empty case through context:
<insert context="list" ref="a" origin="../blank/a"/>

That form is unambiguous, and I support it as specified.

So my questions:


  1.  Is the behaviour for ref="list/a" on an empty list intended? Or is the expectation that authors always use context when the list may be empty?
  2.  If it is intended, would you consider a note under The insert Element that recommends context + a one-step ref whenever the destination may be empty, with this example? It would have saved me, and I suspect others, a defect.
  3.  Alternatively, would a normative refinement be welcome? For example: when the destination sequence is empty and ref is a path expression whose last step is a child step, the item is inserted into the node selected by the path without its last step, if that selects an element. Otherwise the context node is used as today. Until I  hear otherwise, my implementation does this as a declared extension, and keeps the specified behaviour for a one-step ref, for context and for an omitted ref.

Thank you for your time,


With regards,

[DRAKE Solutions]

Mgr. Ivan Turčan
Founder, Senior Software Engineer

DRAKE Solutions s.r.o.
Na Troskách 26
974 01 Banská Bystrica, Slovensko

M   +421 905 500 958<tel:+421905500958>
E   ivan.turcan@drake.sk<mailto:ivan.turcan@drake.sk>
W   www.drake.sk<https://www.drake.sk>



Sídlo spoločnosti: Borovicová 6686/27, 974 05 Banská Bystrica, Slovensko
IČO: 47868244   |   IČ DPH: SK2024122320

Received on Wednesday, 4 November 2026 06:59:33 UTC