W3C home > Mailing lists > Public > www-forms@w3.org > July 2006

Re: xforms 1.1 xf:insert examples

From: Erik Bruchez <ebruchez@orbeon.com>
Date: Tue, 25 Jul 2006 12:06:05 +0200
Message-ID: <44C5ED0D.7090108@orbeon.com>
To: www-forms@w3.org

 > 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 
 > 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" 

then the result will be:

     <name>beginner muppet</name>

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>.


Orbeon - XForms Everywhere:
Received on Tuesday, 25 July 2006 10:06:09 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:36:18 UTC