insert an element into an instance in xforms:model

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

insert an element into an instance in xforms:model

srikanth.prodigy

Hello All,

 

<new-company>

<friend xmlns:xmldb="http://exist-db.org/xquery/xmldb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xdb="http://orbeon.org/oxf/xml/xmldb" xmlns:xu="http://www.xmldb.org/xupdate">

<screenName>10114</screenName>

<portraitId>0</portraitId>

<email>[hidden email]</email>

<ischeckedin/>

<comment></comment>

</friend>

<friend xmlns:xmldb="http://exist-db.org/xquery/xmldb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xdb="http://orbeon.org/oxf/xml/xmldb" xmlns:xu="http://www.xmldb.org/xupdate">

<screenName>srikanth</screenName>

<portraitId>0</portraitId>

<email>[hidden email]</email>

<ischeckedin/>

<comment></comment>

</friend>

</new-company>

------------------------------------------------------------------

 

<Response>

<EventReference>

<friends>

<id>10114</id>

<comment>hi</comment>

</friends>

</EventReference>

<EventReference>

<friends>

<id>10164</id>

<comment>hello</comment>

</friends>

</EventReference>

</Response>

I’m trying to set value comment element in first instance from second instance in xforms model  but the values are not set in first instance

 

<xforms:action ev:event="xforms-ready" xxforms:iterate="instance('friendslist')/EventReference/friends/comment">

                <xforms:setvalue ref="instance('friend')/friend/comment" value="context()"/>

                

            </xforms:action>  

 

Thanks,

Srikanth A

 



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: insert an element into an instance in xforms:model

Alessandro Vernet
Administrator
Srikanth,

srikanth.prodigy wrote
I'm trying to set value comment element in first instance from second
instance in xforms model  but the values are not set in first instance
This should do the trick:

<xforms:action xxforms:iterate="instance('response')/EventReference/friends/comment">
    <xxforms:variable name="position" select="position()"/>
    <xxforms:variable name="source" select="."/>
    <xforms:setvalue ref="(instance('new-company')/friend/comment)[$position]" value="$source"/>
</xforms:action>

I've put this in a full example, you can run it here:
http://www.orbeon.com/ops/xforms-sandbox/run?url=http://pastie.org/487815.txt

And the source is: http://pastie.org/487815.txt

(Note that I renamed your <comment> in <note> just because our HTML formatter does something special with elements named <comment>.)

Alex