Re: xforms 1.1 xf:insert examples

Hi,

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?
2) Or does the processor create a muppet directory and then insert name 
underneath it?

 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.

Any clarification appreciated.

Thanks,
--Aaron



Erik Bruchez wrote:
> 
> Aaron Reed wrote:
>>
>> Hi,
>>
>> As a suggestion for the XForms 1.1 spec, for the section on the insert 
>> action, I'd suggest a few more 'after' examples.  We can see the 
>> 'before' instance data, but we don't see the 'after' instance data 
>> after the action has occurred.
>>
>> Also, it is not immediately apparent to me after reading this section 
>> and the examples what the context node is for evaluating @nodeset.  It 
>> should be the context node of the insert action UNLESS @context is 
>> there and then it is relevant to that node?  Do I have that right?  
>> And the context node for @context, is the context node for the insert 
>> action?
> 
> Yes, I think this has been clarified a little in the latest internal 
> drafts. The idea is that @context evaluates as you expect, i.e. in the 
> context of the action element, and then @context actually _replaces_ the 
> context for that action element, which means that @nodeset and @origin 
> evaluate now within the context created by @context.
> 
> There is a thought of extending the use of @context to all action 
> elements, but this probably won't make it into 1.1, so for now @context 
> is usable only on xforms:insert and xforms:delete.
> 
>>
>> so for:
>>
>> <xf:model id="mymodel">
>>   <xf:instance id="instance0" xmlns="">
>>     ...
>>   </xf:instance>
>>   <xf:instance id="instance1" xmlns="">
>>     <instanceData>
>>       <muppets>
>>         <muppet>
>>           <name>Kermit the Frog</name>
>>           <description>stage manager</description>
>>           <description>frog</description>
>>         </muppet>
>>         <muppet>
>>           <name>Swedish Chef</name>
>>           <description>Swedish</description>
>>           <description>chef</description>
>>           <description>wears a hat</description>
>>         </muppet>
>>         <muppet>
>>           <name>Animal</name>
>>         </muppet>
>>       </muppets>
>>     </instanceData>
>>   </xf:instance>
>>   <xf:instance id="template">
>>     <templates>
>>       <description>main character</description>
>>       <description>secondary chardescription>
>>     </templates>
>>   </xf:instance>
>> </xf:model>
>>
>> ....
>>
>> <xf:group ref="instance('instance1')/instanceData">
>>   <xf:trigger ref="muppets/muppet">
>>     <xf:label>trigger label</xf:label>
>>     <xf:insert context="../muppet[2]" nodeset="description[3]" 
>> origin="instance('template')/description[2]" position="before"/>
>>   </xf:trigger>
>> </xf:group>
>>
>> Would activating this trigger leave us with this?
>>
>>   <xf:instance id="instance1" xmlns="">
>>     <instanceData>
>>       <muppets>
>>         <muppet>
>>           <name>Kermit the Frog</name>
>>           <description>stage manager</description>
>>           <description>frog</description>
>>         </muppet>
>>         <muppet>
>>           <name>Swedish Chef</name>
>>           <description>Swedish</description>
>>           <description>chef</description>
>> ***       <description>secondary character</description> ***
>>           <description>wears a hat</description>
>>         </muppet>
>>         <muppet>
>>           <name>Animal</name>
>>         </muppet>
>>       </muppets>
>>     </instanceData>
>>   </xf:instance>
>>
>> If I my understanding about evaluation contexts is wrong above, then 
>> what would happen?
> 
> Note that you have two errors in your code above. Replace:
> 
>   <xf:group ref="instance('instance1')/instanceData">
> 
> with:
> 
>   <xf:group ref="instance('instance1')">
> 
> You are also missing an ev:event attribute on your action:
> 
>   <xforms:insert ev:event="DOMActivate" ...
> 
> With these changes, you result will be exactly as you say, and it works 
> exactly like that in Orbeon PresentationServer.
> 
> -Erik
> 

Received on Monday, 24 July 2006 23:56:42 UTC