Hi List,
I've seen the examples on replacing xforms:copy with a combination of xforms:insert and delete, and this works fine for select1, but I'm having trouble working out a solution using xforms:select. Below is a simple example of what I have, the first xforms:select is the one I'm working on, the second is the working version using xforms:copy. I know I need to iterate through the values generated by the xforms:select, I'm just not sure how to do this. Essentially for every item populated by the select I need to find the match in the selectTopic instance and insert it into the working instance (metadata). I can do this fine if there is one value, but do not know how to do a loop for all the values in selected. Thanks for your help. -Winona <?xml version="1.0" encoding="UTF-8"?> <html xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mets="http://www.loc.gov/METS/" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:mods="http://www.loc.gov/mods/v3" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Update Descriptive Metadata</title> <meta http-equiv="Pragma" content="no-cache"/> <xforms:model> <xforms:instance id="metadata"> <mods:mods xmlns:mods="http://www.loc.gov/mods/v3"> <mods:identifier type="local">mcalA04F07i09</mods:identifier> <mods:subject xlink:href="http://cdi.uvm.edu/authorities/lg0001"> <mods:geographic authority="local">Potash Brook (Vt.)</mods:geographic> </mods:subject> </mods:mods> </xforms:instance> <xforms:instance id="selectTopic"> <mods:mods xmlns:mods="http://www.loc.gov/mods/v3"> <mods:subject label="Airplanes"> <mods:subject xlink:href="http://cdi.uvm.edu/authorities/sh85002782"> <mods:topic authority="lcsh">Airplanes</mods:topic> </mods:subject> </mods:subject> <mods:subject label="Animals"> <mods:subject xlink:href="http://cdi.uvm.edu/authorities/sh85005249"> <mods:topic authority="lcsh">Animals</mods:topic> </mods:subject> </mods:subject> </mods:mods> </xforms:instance> <xforms:instance id="addTopic"> <mods:mods xmlns:mods="http://www.loc.gov/mods/v3"> <mods:temp/> </mods:mods> </xforms:instance> </xforms:model> </head> <body> <p>Testing insert</p> <xforms:select ref="instance('addTopic')/mods:temp" appearance="full"> <xforms:itemset nodeset="instance('selectTopic')/child::*[descendant-or-self::*/mods:topic]"> <xforms:label style="display: block;" ref="@label"/> <xforms:value ref="mods:subject/@xlink:href"/> </xforms:itemset> </xforms:select> <xforms:trigger class="add"> <xforms:label>Add Selected Subjects</xforms:label> <xforms:action ev:event="DOMActivate"> <xforms:insert context="instance('metadata')" nodeset="instance('metadata')//mods:mods/child::*" at="last()" position="after" origin="instance('selectTopic')/child::*/child::*[@xlink:href = instance(’addTopic’)/child::*]"/> </xforms:action> </xforms:trigger> <p>Working version using xforms:copy</p> <xforms:select ref="instance('addTopic')/child::*" appearance="full"> <xforms:label/> <xforms:itemset nodeset="instance('selectTopic')/child::*[descendant-or-self::*/mods:topic]"> <xforms:label style="display: block;" ref="@label"/> <xforms:copy ref="child::*"/> </xforms:itemset> </xforms:select> <br class="clear"/> <xforms:trigger class="add"> <xforms:label>Add Selected Subjects</xforms:label> <xforms:action ev:event="DOMActivate"> <xforms:insert ev:event="DOMActivate" context="instance('metadata')" nodeset="instance('metadata')//mods:mods/child::*" at="last()" position="after" origin="instance('addTopic')/child::*/child::*"/> </xforms:action> </xforms:trigger> <xforms:repeat nodeset="instance('metadata')//mods:subject" id="subject"> <xforms:repeat nodeset="mods:topic" id="topic"> <p> <xforms:output ref="parent::*/@authority"> <xforms:label>Authority: </xforms:label> </xforms:output> <xforms:output ref="."> <xforms:label>Topic: </xforms:label> </xforms:output> </p> </xforms:repeat> </xforms:repeat> </body> </html> -- 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 |
Hallo
I am using Orbeon in Portlets. The instance data and schema definition has to get loaded from a db before the Portlet renders the XForms (using OrbeonXFormsFilter) I am quite new with XForms and my first ideas to solve the problem are not good: - Parsing the XForms code and replacing the the nodes <xforms:instance> and <xforms:schema> wont be efficient - Saving instance data and schema definition as a file to inlcude with <xforms:instance id="..." src and <xforms:model id="..." schema wont work because there will be multiple version of that files - I searched for a suitable listener but didnt find any Is a any good and efficient solution? Thank you for your help, Karolin -- 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 |
Administrator
|
In reply to this post by wsalesky
Winona,
On Wed, Oct 14, 2009 at 7:57 PM, Winona Salesky <[hidden email]> wrote: > Below is a simple example of what I have, the first xforms:select is the one > I'm working on, the second is the working version using xforms:copy. I know > I need to iterate through the values generated by the xforms:select, I'm > just not sure how to do this. Essentially for every item populated by the > select I need to find the match in the selectTopic instance and insert it > into the working instance (metadata). I can do this fine if there is one > value, but do not know how to do a loop for all the values in selected. I think it is simpler than what you imagine: there is no need to iterate. The following insert does the trick: <xforms:insert context="instance('metadata')" nodeset="*" at="last()" position="after" origin="instance('selectTopic')/mods:subject/mods:subject[@xlink:href = tokenize(instance('addTopic')/mods:temp, '\s')]"/> In instance('addTopic')/mods:temp, you have a space separated list of URIs. They have been put there by the <xforms:select> based on what the user selected. Doing a tokenize(instance('addTopic')/mods:temp, '\s') returns a sequence of strings, and mods:subject[@xlink:href = tokenize(...)] returns the subjects that have a @xlink:href which is the same as one of the URI in that sequence. The full source of the modified file (which runs in the XForms sandbox) is at: http://pastie.org/655732. I hope this helps, Alex -- Orbeon Forms - Web forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ My Twitter: http://twitter.com/avernet -- 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
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Administrator
|
In reply to this post by Karolin Heiss
Karolin,
On Thu, Oct 15, 2009 at 12:34 AM, Karolin Krieg <[hidden email]> wrote: > I am using Orbeon in Portlets. The instance data and schema definition > has to get loaded from a db before the Portlet renders the XForms (using > OrbeonXFormsFilter) Nowadays, in most cases we load initial data using an <xforms:submission>. In essence making an HTTP call to a service which returns the initial data. If you trigger that call with an <xforms:send> running on xforms-model-construct-done, this will happen before the HTML is sent to the browser, and from the browser/user's perspective, it will be as if the data had been there in-line in the XForms. Alex -- Orbeon Forms - Web forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ My Twitter: http://twitter.com/avernet -- 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
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
In reply to this post by Alessandro Vernet
Thank you that does do the trick.
-Winona On Thu, Oct 15, 2009 at 3:46 AM, Alessandro Vernet <[hidden email]> wrote: Winona, -- 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 |
Administrator
|
Winona,
On Thu, Oct 15, 2009 at 5:11 PM, Winona Salesky <[hidden email]> wrote: > Thank you that does do the trick. Excellent, I am glad it worked. Alex -- Orbeon Forms - Web forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ My Twitter: http://twitter.com/avernet -- 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
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |