Hey there!
-- I want to make a more or specific function to format output of numbers which might -- or might not ;-) -- have a floating point part. E.g. we have the following values, the specified format is given inside the round brackets): * 62 (=> 62 €) * 2581.97 (=> 2.581,97 €) * -2.561 (=> -2,56 €) So I tried to build a modified output myxbl:output (see below). The values will be shown not only as trivial output with labels but also inside xforms:select1 etc. The problem is: I get an error as soon as I use the custom XBL-rule inside an xforms:select1 i.e. as a part of the label of an xforms:item/xforms:itemset inside xforms:select1. The warning is "Nested XHTML or XForms not allowed within element: label" (even though I don't use any label: <myxbl:output-price ref="price"/>) In fact I would have liked it better to define a global format in a properties file and use a specific type or to use an self-defined function (compare to XSLT3/XPath) - bit orbeon doesn't seem to support this. Additionally it seems I can't access any attributes of the custom XBL-element With the XBL I still miss some options: - Add static text as prefix and postfix to the formatted string (e.g. by adding an attribute to <myxbl:output-price pre="$name (available at " post=")"/> yielding an output like 'Boattrip (available at 1.254,97 €)' - Use the "syntactic magic" of <xf:output ref="$price" value=". * 1.25"/> is not possible Is there any option to get around this, enhance my faulty implementation or even to build a better solution? Thanks again for any help, Jens <xbl:xbl xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:saxon="http://saxon.sf.net/" xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:xxbl="http://orbeon.org/oxf/xml/xbl" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:exf="http://www.exforms.org/exf/1-0" xmlns:myxbl="http://www.my.com/myxbl"> <!-- Output a formatted price --> <xbl:binding id="myxbl-output-price" element="myxbl|output-price" xxbl:mode="binding value" xxbl:container="span" xxbl:label-for="output-price"> <xbl:resources> <xbl:style> </xbl:style> </xbl:resources> <xbl:template> <xf:var name="binding" value="if (xxf:binding('myxbl-output-price')) then xxf:binding('myxbl-output-price') else ."/> <xf:var name="currency" value="'€'"/> <xf:var name="format" value="if ($binding castable as xs:decimal) then ( if (abs($binding) != abs(round($binding))) then translate(format-number($binding, concat('#,##0.00 ', $currency)), '.,', ',.') else translate(format-number($binding, concat('#,##0 ', $currency)), '.,', ',.') ) else $binding"/> <xf:output value="$format" xbl:attr="model context bind" id="output-price"> <xbl:content includes=":root > xf|label, :root > xf|hint, :root > xf|help, :root > xf|alert, :root > text()"/> </xf:output> </xbl:template> </xbl:binding> </xbl:xbl> You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. |
Administrator
|
Hi Jens, Right now you can put an xf:output inside an xf:select1/xf:item/xf:label, but you can't put an XBL control that embeds an xf:output, which is a limitation we might be able to raise. For now, if you just need to do this for a dropdown, you could make your component contain a dropdown that does the formatting. Is this something that could work for you? Alex On Fri, May 15, 2015 at 6:27 AM, Jens Thorsten Stumpf <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hey Alex,
-- thank you for your answer. Well, as far as I can see I would have to build two different XBLs (or make some more or less complex stuff with XSLs and additional params). I guess that doesn't help because the needed work outweighs the effect ;-) In the end it's a bit sad one can't use an XBL "created" output in the same way as an "hard coded" output. Is there an option to add my own formatting XPath-function? That's an alternative that would help with a lot of requirements! Thanks again, Jens Am Dienstag, 19. Mai 2015 02:29:07 UTC+2 schrieb Alessandro Vernet:
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. |
Administrator
|
Hi Jens, If you implement your formatting functions in Java (or Scala!), you can call easily them from XPath. This is a feature of Saxon, which Orbeon Forms uses for XPath evaluation. You can find more on this on: Alex On Tue, May 19, 2015 at 7:56 AM, Jens Thorsten Stumpf <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |