In a select I want to get have the value of the elements being their
position in the list <xf:select1 bind="selectedGoal" appearance="compact" style="height:10em" id="goalSelect1" incremental="true"> <xf:itemset bind="goals"> <xf:label> <xf:output ref="stml:SequenceIndicator"/> <xf:output ref="stml:Name"/> </xf:label> <xf:value ref="position()"/> </xf:itemset> </xf:select1> However this produces an error about converting an integer to a nodeset This is the instance, the selectGoal is bound to the goal element <xf:instance xmlns="" id="selectedInstance"> <selected> <goal>1</goal> <goalElement></goalElement> <objective>1</objective> <strategy>1</strategy> <url></url> <language>en</language> </selected> </xf:instance> It has just occurred to me that I could save the element and calculate the id <xf:select1 bind="selectedGoalElement" appearance="compact" style="height:10em" id="goalSelect1" incremental="true"> <xf:itemset bind="goals"> <xf:label> <xf:output ref="stml:SequenceIndicator"/> <xf:output ref="stml:Name"/> </xf:label> <xf:value ref="."/> <xf:action ev:event="xforms-value-changed"> <xf:setvalue bind="selectedGoal" value="xxf:bind('selectedGoalElement')/position()/"/> </xf:action> </xf:itemset> </xf:select1> This doesnt give me an error but doesnt work, I guess because the position() isnt with respect to the parent collection but the instance and so gives me the result of 1 always. Any ideas? Thanks in advance Andy Bailey -- 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
|
The @ref attribute must always return nodes. position() returns a
number, not a node, hence the error. Try the non-standard: <xf:value value="position()"/> -Erik On Mar 1, 2009, at 8:07 PM, Andrew Bailey wrote: > In a select I want to get have the value of the elements being their > position in the list > > <xf:select1 bind="selectedGoal" appearance="compact" > style="height:10em" id="goalSelect1" incremental="true"> > <xf:itemset bind="goals"> > <xf:label> > <xf:output ref="stml:SequenceIndicator"/> > <xf:output ref="stml:Name"/> > </xf:label> > <xf:value ref="position()"/> > </xf:itemset> > </xf:select1> > > However this produces an error about converting an integer to a > nodeset > > This is the instance, the selectGoal is bound to the goal element > <xf:instance xmlns="" id="selectedInstance"> > <selected> > <goal>1</goal> > <goalElement></goalElement> > <objective>1</objective> > <strategy>1</strategy> > <url></url> > <language>en</language> > </selected> > </xf:instance> > > > It has just occurred to me that I could save the element and > calculate the id > > <xf:select1 bind="selectedGoalElement" appearance="compact" > style="height:10em" id="goalSelect1" incremental="true"> > <xf:itemset bind="goals"> > <xf:label> > <xf:output ref="stml:SequenceIndicator"/> > <xf:output ref="stml:Name"/> > </xf:label> > <xf:value ref="."/> > <xf:action ev:event="xforms-value-changed"> > <xf:setvalue bind="selectedGoal" > value="xxf:bind('selectedGoalElement')/position()/"/> > </xf:action> > </xf:itemset> > </xf:select1> > > This doesnt give me an error but doesnt work, I guess because the > position() isnt with respect to the parent collection but the > instance and so gives me the result of 1 always. > > Any ideas? > > Thanks in advance > > Andy Bailey > > -- > 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 |
Ok great, thanks.
<xf:value value="position()"/> worked, any chance of suggesting this for the next xforms spec. I had to add a cast to number, which Im not sure why. ( is this a bug?) <xf:group ref="instance('stratmlInstance')/stml:Goal[number(xxf:bind('selectedGoal'))]"> Andy Bailey http://www.hazlorealidad.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 |
Administrator
|
> Ok great, thanks.
> <xf:value value="position()"/> > worked, any chance of suggesting this for the next xforms spec. Yes, we should suggest it. But feel free to do so as well by sending an email to: [hidden email] > I had to add a cast to number, which Im not sure why. ( is this a > bug?) > > <xf:group ref="instance('stratmlInstance')/ > stml:Goal[number(xxf:bind('selectedGoal'))]"> It's not really a bug as per XForms 1.1: even though you can assign types to instance data nodes, node values are currently used purely as strings. So in this case you need the cast to tell XPath that you want a numeric predicate as opposed to a boolean one. In the future, it would be desirable to honor node types, as XSLT 2.0 does in schema-aware mode. -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 |