Menu

#8 Insert into empty repeat doesn't work

open
None
5
2009-03-28
2009-03-27
No

In certain common cases, inserting into a an empty repeat (as in the example in section 10.3 of XForms 1.1) doesn't work.

Instance looks like this:
<data>
<source>
<item>baseline</item>
</source>
<dest1><item>Initially non-empty</item></dest1>
<dest2></dest2>
...
</data>

The repeat looks like this, say for dest2:
<xf:repeat id="destination-repeat2" nodeset="dest2/item">
<xf:output ref="."/>
</xf:repeat>

And the insert looks like this:
<xf:insert origin="source/item" nodeset="dest2/item"/>

to no effect. Adding an <item> element under <dest2> (like the working dest1 case does) allows the insert to complete.

This seems to be related to the structure of the instance data. A similar case, where origin and destination are at different levels, appears to work fine. The arrangement is the same, but the instance data looks like:
<purchaseOrder xmlns="">
<templ>
<item>PROTO</item>
</templ>
</purchaseOrder>

With the insert arranged to produce /purchaseOrder/item, it works, even into an empty repeat.

Full example attached.

Discussion

  • Micah Dubinko

    Micah Dubinko - 2009-03-27

    Test case showing failure. "Destination 2" repeat should be populated with the "baseline" item

     
  • Alain Couthures

    Alain Couthures - 2009-03-28
    • assigned_to: nobody --> alain-couthures