Hi -
I had a quick question and just wanted to see whether anyone else in this forum had noticed a similar situation. Within an XForm, I can do this: <xhtml:p> <xf:group ref=".[count(/items/item) > 1]"> Items </xf:group> <xf:group ref=".[count(/items/item) < 2]"> Item </xf:group> </xhtml:p> And it works perfectly :) However, I was hoping I could add similar code inside an <xf:label> tag, so idea would be that the label would dynamically update when multiple 'item's are found in the instance. As the code works on its own I'm wondering whether this kind of thing isn't allowed within <xf:label /> tags or whether there is another way to achieve this effect (XPath 2.0 notation perhaps?) Has anyone else added dynamically updating content inside an <xf:label /> before? Any ideas would be greatly appreciated as always - thanks :) |
Hi Alex,
> As the code works on its own I'm wondering whether this kind of thing isn't > allowed within <xf:label /> tags or whether there is another way to achieve > this effect (XPath 2.0 notation perhaps?) Has anyone else added dynamically > updating content inside an <xf:label /> before? i think you can't use the technique of xforms:group as you've shown for xforms:label. The easiest solution in your case is IMHO to use the xpath if function inside a xforms:output: <xforms:label> <xforms:output value="if (count(/items/item) lt 2) then 'single' else 'multiple'" /> </xforms:label> 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 |
In reply to this post by Alex Bleasdale
Hi Alex,
There are a couple of things you could try. One is to use a ref attribute on the label, something like <xf:label ref="if (count(/items/item) > 1) then /labels/myLabelMany else /labels/myLabelOne"/> The other is to put an output inside the label, with a suitable value attribute, such as <xf:label><xf:output value="if (count(/items/item) > 1) then 'Items' else 'Item'"/></xf:label> The first approach is nice and neat but only works if you have an instance node to point to: the second approach can use any XPath expression, including string literals or combining values at different locations. Cheers, Dave Alex Bleasdale wrote: > Hi - > > I had a quick question and just wanted to see whether anyone else in this > forum had noticed a similar situation. Within an XForm, I can do this: > > > <xhtml:p> > <xf:group ref=".[count(/items/item) > 1]"> > Items > </xf:group> > > <xf:group ref=".[count(/items/item) < 2]"> > Item > </xf:group> > </xhtml:p> > > And it works perfectly :) > > However, I was hoping I could add similar code inside an <xf:label> tag, so > idea would be that the label would dynamically update when multiple 'item's > are found in the instance. > > As the code works on its own I'm wondering whether this kind of thing isn't > allowed within <xf:label /> tags or whether there is another way to achieve > this effect (XPath 2.0 notation perhaps?) Has anyone else added dynamically > updating content inside an <xf:label /> before? > > Any ideas would be greatly appreciated as always - thanks :) > -- 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 |