I desire the capability to update multiple XML nodes at once. I have a repeat nodeset and would like to select certain nodes from my list and edit certain attributes for all selected attributes.
Can anyone put me on the right path? |
I'm not sure to understand what you need (atomic transaction for multiple nodeset update or multiple node update for a single nodeset), so:
--- Update multiple nodes in a nodeset --- let $yournodeset:= <nodeset> <element attr1="x">new value</element> <element attr1="y">another1</element> <element attr1="z">new value</element> </nodeset> let $dummy:= for $n in ($yournodeset/element[@attr1=('x','z')]) return update value $n with concat($n/text(),'-new value') return $yournodeset result: <nodeset> <element attr1="x">content-new value</element> <element attr1="y">another1</element> <element attr1="z">again-new value</element> </nodeset> Which means: - iterate all "element" nodes with attr1 value = 'x' or 'z' - for each selected node replace element content (value) with original content + '-new value' constant - print back new nodeset -- Update multiple nodesets within a single transaction --- From exist-db doc (here): (# exist:batch-transaction #) { UPDATE_a , UPDATE_b , ... UPDATE_c } Where: UPDATE_x is an xql update statement (involving a single nodeset) |
In reply to this post by lkbrown
Paolo,
I was referring to "Update multiple nodes in a nodeset." Thanks for the explanation. Is that xquery code? how would I implement in an xform? |
Yes, this is xquery code. Orbeon can read and write data from/to exist (embedded xml-db).
I usually get data (and append/update/delete) data from embedded exist db using .xql files (or stored exist-db queries): to execute an xql query I code xforms submission like this: <xforms:submission id="save" action="updatenode.xql" ref="instance('instance')" method="post" replace="none"> where updatenode.xql (which resides in current context appliction path) is responsible to parse incoming node (ref="instance('instance')") data and to update original nodeset with modified data (this is updatenode.xql): xquery version "1.0"; declare namespace request="http://exist-db.org/xquery/request"; declare namespace xmldb="http://exist-db.org/xquery/xmldb"; declare namespace util="http://exist-db.org/xquery/util"; declare option exist:serialize "method=xml media-type=text/xml"; let $node:=request:get-data() (: <--- I'm reading post parameters (instance passed from xform) :) let $dummy:=update replace //*[@ID=$node/@ID] with $node (: update node ID=xxx :) return //*[@ID=$node/@ID] (: <-- post back updated node :) Does this example point you to the right direction? |
I am out of the office until 19th April *********************************************************************************************** This email, including any attachment, is confidential and may be legally privileged. If you are not the intended recipient or if you have received this email in error, please inform the sender immediately by reply and delete all copies from your system. Do not retain, copy, disclose, distribute or otherwise use any of its contents.
Whilst we have taken reasonable precautions to ensure that this email has been swept for computer viruses, we cannot guarantee that this email does not contain such material and we therefore advise you to carry out your own virus checks. We do not accept liability for any damage or losses sustained as a result of such material.
Please note that incoming and outgoing email communications passing through our IT systems may be monitored and/or intercepted by us solely to determine whether the content is business related and compliant with company standards. *********************************************************************************************** The Stationery Office Limited is registered in England No. 3049649 at 10 Eastbourne Terrace, London, W2 6LG
|
In reply to this post by Paolo Nacci
Paolo, Thanks for the explanation. However, my problem is a little bit different. I am trying to make
the same change to multiple nodes. For instance, I have a list of 10 students represented in a
table. I want to select 5 of them and change a common attribute (i.e enrolled
) to true for all selected notes. Any clue how to implement this? From: Paolo Nacci [via Orbeon Forms (ops-users)]
[mailto:[hidden email]] Yes, this is xquery code. Orbeon can read and write
data from/to exist (embedded xml-db). View message @ http://n4.nabble.com/Edit-Multiple-Nodes-at-Once-tp1837541p1839153.html
|
I am out of the office until 19th April *********************************************************************************************** This email, including any attachment, is confidential and may be legally privileged. If you are not the intended recipient or if you have received this email in error, please inform the sender immediately by reply and delete all copies from your system. Do not retain, copy, disclose, distribute or otherwise use any of its contents.
Whilst we have taken reasonable precautions to ensure that this email has been swept for computer viruses, we cannot guarantee that this email does not contain such material and we therefore advise you to carry out your own virus checks. We do not accept liability for any damage or losses sustained as a result of such material.
Please note that incoming and outgoing email communications passing through our IT systems may be monitored and/or intercepted by us solely to determine whether the content is business related and compliant with company standards. *********************************************************************************************** The Stationery Office Limited is registered in England No. 3049649 at 10 Eastbourne Terrace, London, W2 6LG
|
In reply to this post by lkbrown
Let me see if I understand... You have an xml database with many nodes (records) like: <students> <student ID="AA001" an_attribute="N"><enrolled>false</enrolled></student> <student ID="AA002" an_attribute="Y"><enrolled>false</enrolled></student> <student ID="AA003" an_attribute="N"><enrolled>false</enrolled></student> ... <student ID="AAnnn" an_attribute="N"><enrolled>false</enrolled></student> </student> you want to update a "selection" of students (who makes selection? user through a form?) with and set them to <enrolled>true</enrolled> If so, you can update an instance with selected ids, then use it when update: ... <xforms:instance id="parms"> <parms> <selectedids/> </parms> </xforms:instance> ... <xforms:instance id="update-instance"> <exist:query> <exist:text> update replace //student[@ID = {instance('parms')/selectedids}]/enrolled with <enrolled>true</enrolled> </exist:text> </exist:query> </xforms:instance> ... <xforms:submission id="myupdate" ref="instance('update-instance')" action="/exist/rest/db/" method="post" replace="none"/> .... |
I've seen the "java-authentication" example, and was wondering what you feel would be the best (read: most elegant) way to modify it to allow field-level security based on users' roles.
We are building a system that allows our users to submit "research applications" to the research department on campus. I have just enough of Orbeon and XForms figured out to get the forms set up, but our system has a set of security requirements: * Once a form is submitted, only people with certain security roles can view / edit / add certain elements or pages of each form Example: If I am a research coordinator, I should be able to reopen a filled form and edit anything that was submitted by the original author. However, If I am only a submission reviewer, I should only be able to read elements on the first page, edit one field on the second page, not see ANYTHING on the third page, and so on. * Once a "research application" has been reviewed and approved, these role permissions can change (we have a REST service that is called that gets status information based on application ID) Example: The original author should be able to completely edit a previously submitted form while it is under review. However, once it has been reviewed, certain fields should be changed to read-only. Thank you! Matt Baker University of Arkansas for Medical Sciences -- 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 |
It's a little bit "off-topic", but, to manage role based forms and fields you could: a) assign a "level" to users (0 = guest, ..., 99 = admin) b) use attributes on fields and nodes to map levels to actions (<node view="0" edit="nn" full_control="nn"/>) c) assign a status to nodes d) record user name within node e) bind relevant / readonly to nodes/elements/attributes like: <bind nodeset="instance('your-data-instance')/node" relevant="@view<current_user_level and @status=a_valid_status_to_view_data" readonly="not(current_user_level=99) and (@edit<current_user_level or @user!=current_user or @status=locked)"/> "minimum level" approach is quite simplicistic, a more complex could be "role based", where an user could be mapped to one or more roles, and node security could be in a different document (linked to data by an idref field <fieldef ID="FIELDCODE" and all security requirements/> <data fieldtype="FIELDCODE" and all node content>) |
Administrator
|
In reply to this post by lkbrown
If you'd like to do this at the XForms level (rather than in the
database), you can use the xxforms:iterate construct. For instance: <xforms:action xxforms:iterate="/class/students[@has-passing-grade = 'true']"> <xforms:setvalue ref="@grade" value=". + 1"/> </xforms:action> You prefer, you can write this in one line with: <xforms:setvalue xxforms:iterate="/class/students[@has-passing-grade = 'true']" ref="@grade" value=". + 1"/> Alex On Wed, Apr 14, 2010 at 12:15 PM, lkbrown <[hidden email]> wrote: > Paolo, > > > > Thanks for the explanation. > > > > However, my problem is a little bit different. I am trying to make the same > change to multiple nodes. > > For instance, I have a list of 10 students represented in a table. I want to > select 5 of them and change a common attribute (i.e enrolled ) to true for > all selected notes. > > > > Any clue how to implement this? > > > > From: Paolo Nacci [via Orbeon Forms (ops-users)] [mailto:[hidden email]] > Sent: Tuesday, April 13, 2010 8:09 PM > To: Brown, Lyndon K. > Subject: Re: Edit Multiple Nodes at Once > > > > Yes, this is xquery code. Orbeon can read and write data from/to exist > (embedded xml-db). > I usually get data (and append/update/delete) data from embedded exist db > using .xql files (or stored exist-db queries): to execute an xql query I > code xforms submission like this: > <xforms:submission id="save" action="updatenode.xql" > ref="instance('instance')" method="post" replace="none"> > > where updatenode.xql (which resides in current context appliction path) is > responsible to parse incoming node (ref="instance('instance')") data and to > update original nodeset with modified data > > (this is updatenode.xql): > xquery version "1.0"; > declare namespace request="http://exist-db.org/xquery/request"; > declare namespace xmldb="http://exist-db.org/xquery/xmldb"; > declare namespace util="http://exist-db.org/xquery/util"; > declare option exist:serialize "method=xml media-type=text/xml"; > > let $node:=request:get-data() (: <--- I'm reading post parameters (instance > passed from xform) :) > let $dummy:=update replace //*[@ID=$node/@ID] with $node (: update node > ID=xxx :) > return //*[@ID=$node/@ID] (: <-- post back updated node :) > > Does this example point you to the right direction? > > ________________________________ > > View message @ > http://n4.nabble.com/Edit-Multiple-Nodes-at-Once-tp1837541p1839153.html > To unsubscribe from Re: Edit Multiple Nodes at Once, click here. > > > > ________________________________ > View this message in context: RE: Edit Multiple Nodes at Once > Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com. > > > -- > 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 > > -- Orbeon Forms - Web forms, open-source, for the Enterprise - http://www.orbeon.com/ 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 |