Using an xforms:select places all the selected strings into one XML
element, separated by spaces. Is there some way to iterate through
those strings and surround each one with an XML element?
For example, if the xforms:select puts the strings A, B, and C into <result>A B C</result>how can I convert that into the following? <foo>Thanks, -Jim -- 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 |
This was discussed before on this list. Check the thread below - maybe
that will be helpful: http://www.nabble.com/forum/ViewPost.jtp?post=15311855&framed=y A. On Jul 12, 2008, at 7:25 AM, Jim Logan wrote: > Using an xforms:select places all the selected strings into one XML > element, separated by spaces. Is there some way to iterate through > those strings and surround each one with an XML element? > > For example, if the xforms:select puts the strings A, B, and C into > <result>A B C</result> > how can I convert that into the following? > <foo> > <bar>A</bar> > <bar>B</bar> > <bar>C</bar> > </foo> > Thanks, > -Jim > > > -- > 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 -- 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 |
Alexander Žaťko wrote:
> This was discussed before on this list. Check the thread below - maybe > that will be helpful: > > http://www.nabble.com/forum/ViewPost.jtp?post=15311855&framed=y I don't understand the answer, which was, "select/itemset/copy will work." Can someone tell me what that means, please? Thanks, -Jim > > On Jul 12, 2008, at 7:25 AM, Jim Logan wrote: > >> Using an xforms:select places all the selected strings into one XML >> element, separated by spaces. Is there some way to iterate through >> those strings and surround each one with an XML element? >> >> For example, if the xforms:select puts the strings A, B, and C into >> <result>A B C</result> >> how can I convert that into the following? >> <foo> >> <bar>A</bar> >> <bar>B</bar> >> <bar>C</bar> >> </foo> >> Thanks, >> -Jim -- 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 |
Jim,
> I don't understand the answer, which was, "select/itemset/copy will > work." Can someone tell me what that means, please? i think it's a kind of "XPath shortcut" to denote a certain method to include the itemset details for the select. The following message shows a combination of xforms:item (as initial entry), xforms:itemset to reference a set of elements that contain the different entry/value pairs, and a xforms:copy to "import" the entry/value children of that itemset. http://www.nabble.com/xforms%3Acopy-workaround-p15512467.html This is "select/itemset/copy". select/itemset/value is represented by the example at the end of that doc chapter: http://www.orbeon.com/ops/doc/reference-xforms-ng#xforms-controls-list And select/item/value means to put the selection list items directly into the xforms:select as xforms:item. But i suppose you will need to use the delete/insert workaround as in the xforms-copy sandbox example http://www.orbeon.com/ops/xforms-sandbox/sample/xforms-copy HTH florian -- 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 |
Florian Schmitt wrote:
Jim,Florian, Perhaps I'm being dense. I don't understand why the links above are related to trying to use the result of selecting more than one thing in an xforms:select element, which is "A B C" in the quote below. The links above are all discussing the xforms:select1 element, which I already know how to use. I did a little reading of the XForms 1.1 spec. It makes me think the xforms:copy element might do what I need, but then I see in the messages at the links you provided that Orbeon does not implement the xforms:copy element. Could you please clarify how I get each of the space-separated strings into its own XML element? Thanks, -Jim Jim Logan wrote: Using an xforms:select places all the selected strings into one XML element, separated by spaces. Is there some way to iterate through those strings and surround each one with an XML element?
-- 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 |
Jim,
> Perhaps I'm being dense. I don't understand why the links above are > related to trying to use the result of selecting more than one thing in > an xforms:select element, which is "A B C" in the quote below. The links > above are all discussing the xforms:select1 element, which I already > know how to use. hmm - i thought that it's basically the same problem. In your example, the string "A B C" is the result of concatenating the text value of three elements selected from the itemset, so i thougth this case is comparable to that where only one element from an itemset is selected. Of course, you could work on the string "A B C" to create corresponding instance elements. But i thought it would be easier to avoid the concatenation/split and work on the elements itself. > I did a little reading of the XForms 1.1 spec. It makes me think the > xforms:copy element might do what I need, but then I see in the messages > at the links you provided that Orbeon does not implement the xforms:copy > element. Could you please clarify how I get each of the space-separated > strings into its own XML element? If i understood it correctly, the solutions proposed in the mentioned thread don't work with the string output. Both work with the selected elements. If you really want to work with the concatenated string, there are different ways. You could split it up using JavaScript or XSLT and process the results. A quite elegant way might be to use a nightly build and apply the xxforms:iterate function [1] after tokenizing the string. Something like <xforms:action ev:event="DOMFocusOut" xxforms:iterate="tokenize(/nodeWithSelection, ' ')"> <xforms:insert context="instance('main-instance')" nodeset="book" origin="instance('template-instance')"/> <xforms:setvalue ref="instance('main-instance')/book[last()]/title" value="context()"/> <xforms:setvalue ref="instance('main-instance')/book[last()]/author" value="context()/following-sibling::author"/> </xforms:action> but i don't know whether this will work. HTH florian [1] http://www.orbeon.com/ops/doc/reference-xforms-2#exforms-iterate -- 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
|
I have an easy answer for you:
<xforms:insert context="path/to/foo" origin="for $value in tokenize(path/to/result, '\s') return xxforms:element('bar', $value)"/> I haven't run it, but something along these lines should work. -Erik On Jul 14, 2008, at 12:40 AM, Florian Schmitt wrote: > Jim, > >> Perhaps I'm being dense. I don't understand why the links above are >> related to trying to use the result of selecting more than one >> thing in an xforms:select element, which is "A B C" in the quote >> below. The links above are all discussing the xforms:select1 >> element, which I already know how to use. > > hmm - i thought that it's basically the same problem. In your > example, the string "A B C" is the result of concatenating the text > value of three elements selected from the itemset, so i thougth this > case is comparable to that where only one element from an itemset is > selected. Of course, you could work on the string "A B C" to create > corresponding instance elements. But i thought it would be easier to > avoid the concatenation/split and work on the elements itself. > >> I did a little reading of the XForms 1.1 spec. It makes me think >> the xforms:copy element might do what I need, but then I see in the >> messages at the links you provided that Orbeon does not implement >> the xforms:copy element. Could you please clarify how I get each of >> the space-separated strings into its own XML element? > > If i understood it correctly, the solutions proposed in the > mentioned thread don't work with the string output. Both work with > the selected elements. > > If you really want to work with the concatenated string, there are > different ways. You could split it up using JavaScript or XSLT and > process the results. A quite elegant way might be to use a nightly > build and apply the xxforms:iterate function [1] after tokenizing > the string. Something like > > <xforms:action > ev:event="DOMFocusOut" > xxforms:iterate="tokenize(/nodeWithSelection, ' ')"> > <xforms:insert > context="instance('main-instance')" > nodeset="book" > origin="instance('template-instance')"/> > <xforms:setvalue > ref="instance('main-instance')/book[last()]/title" > value="context()"/> > <xforms:setvalue > ref="instance('main-instance')/book[last()]/author" > value="context()/following-sibling::author"/> > </xforms:action> > > but i don't know whether this will work. > > HTH > florian > > [1] http://www.orbeon.com/ops/doc/reference-xforms-2#exforms-iterate > > > > -- > 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 for the Enterprise Done the Right Way http://www.orbeon.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 |
In reply to this post by fl.schmitt(ops-users)
Florian Schmitt wrote:
> > If i understood it correctly, the solutions proposed in the mentioned > thread don't work with the string output. Both work with the selected > elements. > Your way might be better, but I just don't understand what you're saying I should do with a multiple selection to get the effect I want. Could you give me an example maybe? > If you really want to work with the concatenated string, there are > different ways. You could split it up using JavaScript or XSLT and > process the results. A quite elegant way might be to use a nightly > build and apply the xxforms:iterate function [1] after tokenizing the > string. Something like > > <xforms:action > ev:event="DOMFocusOut" > xxforms:iterate="tokenize(/nodeWithSelection, ' ')"> > <xforms:insert > context="instance('main-instance')" > nodeset="book" > origin="instance('template-instance')"/> > <xforms:setvalue > ref="instance('main-instance')/book[last()]/title" > value="context()"/> > <xforms:setvalue > ref="instance('main-instance')/book[last()]/author" > value="context()/following-sibling::author"/> > </xforms:action> > > but i don't know whether this will work. I wasn't able to get it working. I finally had to use a repeat, which gives the first link an undesirable orange-ish background. I didn't have an event that triggered the action, so maybe that was the problem. Is it possible to iterate without a triggering event? Thanks, -Jim -- 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 |
In reply to this post by Erik Bruchez
Erik Bruchez wrote:
> I have an easy answer for you: > > <xforms:insert > context="path/to/foo" > origin="for $value in tokenize(path/to/result, '\s') return > xxforms:element('bar', $value)"/> That looks really cool! I wish I had seen this before I gave up and rewrote my form to take a different approach. Thanks, -Jim -- 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 |
In reply to this post by Jim Logan-3
Jim Logan wrote:
Florian Schmitt wrote:Bump... Anyone? Thanks, -Jim -- 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
|
>> That looks interesting. Just yesterday I needed a way to iterate
>> through a set of strings and use each of those strings to form a >> hyperlink, but I wasn't able to get it working. I finally had to >> use a repeat, which gives the first link an undesirable orange-ish >> background. I didn't have an event that triggered the action, so >> maybe that was the problem. Is it possible to iterate without a >> triggering event? > Bump... > > Anyone? Can you precise your question? -Erik -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.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 |
Free forum by Nabble | Edit this page |