Re: xforms 1.1 xf:insert examples

Aaron,
 > I've got a follow-up question.  Since it seems I have a decent grip on
 > how things should work, I was wondering what happens not only of the
 > nodeset is empty, but what if the parent node of the nodeset doesn't 
exist.
 >
 > Assume that I have this in my form:
 >
 > <xf:instance id="instance1" xmlns="">
 >   <instanceData>
 >     <muppets/>
 >   </instanceData>
 > </xf:instance>
 > <xf:instance id="template">
 >   <templates>
 >     <name>beginner muppet</name>
 >   </templates>
 > </xf:instance>
 > ....
 > <xf:group ref="instance('instance1')">
 >   <xf:trigger ref="muppets">
 >     <xf:label>trigger label</xf:label>
 >     <xf:insert nodeset="muppet/name" origin="instance('template')/name"/>
 >   </xf:trigger>
 > </xf:group>
 >
 > You can see that there is no muppets/muppet directory, so where does the
 > clone of instance('template')/name get put?
 > 1)Does it go underneath the insert context node?  In this case would it
 > get put under muppets?

With your code above, neither this...

 > 2) Or does the processor create a muppet directory and then insert name
 > underneath it?

...nor that ;-) With your code, the operation just doesn't do
anything, because the insert nodeset is empty and you do not specify
an insertion context with the @context attribute.

 > From my interpretation of the spec, I'd think that the answer is #1,
 > but I'd also think, logically speaking, that if I do an insert into an
 > empty nodeset and it is successful then the previously empty nodeset
 > should no longer be empty.

If you change your code above to specify an insertion context:

<xf:insert context="." nodeset="muppet/name" 
origin="instance('template')/name"/>

then the result will be:

<instanceData>
   <muppets>
     <name>beginner muppet</name>
   </muppets>
</instanceData>

As long as you don't have an element called <muppet> under <muppets>,
the insert nodeset will be empty, so you always fall back to the case
where the @context attribute is used and therefore the insertion
happens as a child of <muppets>.

-Erik

-- 
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/

Received on Tuesday, 25 July 2006 10:06:09 UTC