XBL or other option to format numbers in output

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

XBL or other option to format numbers in output

Jens Thorsten Stumpf
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&#160;', $currency)), '.,', ',.')
                    else translate(format-number($binding, concat('#,##0&#160;', $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].
Reply | Threaded
Open this post in threaded view
|

Re: XBL or other option to format numbers in output

Alessandro  Vernet
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:
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&#160;', $currency)), '.,', ',.')
                    else translate(format-number($binding, concat('#,##0&#160;', $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].

--
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
Reply | Threaded
Open this post in threaded view
|

Re: XBL or other option to format numbers in output

Jens Thorsten Stumpf
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:
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 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Rb9bMjpyhlsJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">thun...@...> wrote:
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="<a href="http://www.w3.org/1999/xhtml" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml\46sa\75D\46sntz\0751\46usg\75AFQjCNFPnvHmzp7QdvEjpI1OxPKiChMEFw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml\46sa\75D\46sntz\0751\46usg\75AFQjCNFPnvHmzp7QdvEjpI1OxPKiChMEFw';return true;">http://www.w3.org/1999/xhtml"
         xmlns:xf="<a href="http://www.w3.org/2002/xforms" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2F2002%2Fxforms\46sa\75D\46sntz\0751\46usg\75AFQjCNFsT85FCBgT3Vtrgkvw8OwGlGHT8w';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2F2002%2Fxforms\46sa\75D\46sntz\0751\46usg\75AFQjCNFsT85FCBgT3Vtrgkvw8OwGlGHT8w';return true;">http://www.w3.org/2002/xforms"
         xmlns:xs="<a href="http://www.w3.org/2001/XMLSchema" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema\46sa\75D\46sntz\0751\46usg\75AFQjCNETUl7MhKy2nWpH8V8BwGakc8etag';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema\46sa\75D\46sntz\0751\46usg\75AFQjCNETUl7MhKy2nWpH8V8BwGakc8etag';return true;">http://www.w3.org/2001/XMLSchema"
         xmlns:ev="<a href="http://www.w3.org/2001/xml-events" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2F2001%2Fxml-events\46sa\75D\46sntz\0751\46usg\75AFQjCNFff_qDKy8FnFbQ86MbMH1vwe7NKw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2F2001%2Fxml-events\46sa\75D\46sntz\0751\46usg\75AFQjCNFff_qDKy8FnFbQ86MbMH1vwe7NKw';return true;">http://www.w3.org/2001/xml-events"
         xmlns:xxf="<a href="http://orbeon.org/oxf/xml/xforms" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Forbeon.org%2Foxf%2Fxml%2Fxforms\46sa\75D\46sntz\0751\46usg\75AFQjCNFYjEz7mP5L4ajuRx6GqLj9iCyivQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Forbeon.org%2Foxf%2Fxml%2Fxforms\46sa\75D\46sntz\0751\46usg\75AFQjCNFYjEz7mP5L4ajuRx6GqLj9iCyivQ';return true;">http://orbeon.org/oxf/xml/xforms"
         xmlns:fr="<a href="http://orbeon.org/oxf/xml/form-runner" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Forbeon.org%2Foxf%2Fxml%2Fform-runner\46sa\75D\46sntz\0751\46usg\75AFQjCNFIhsOO7At2JqHaGk5a2HYUXk_bVQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Forbeon.org%2Foxf%2Fxml%2Fform-runner\46sa\75D\46sntz\0751\46usg\75AFQjCNFIhsOO7At2JqHaGk5a2HYUXk_bVQ';return true;">http://orbeon.org/oxf/xml/form-runner"
         xmlns:saxon="<a href="http://saxon.sf.net/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fsaxon.sf.net%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHIK1daOplJCXHMkDKdBTz5ubpMbg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fsaxon.sf.net%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHIK1daOplJCXHMkDKdBTz5ubpMbg';return true;">http://saxon.sf.net/"
         xmlns:xbl="<a href="http://www.w3.org/ns/xbl" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2Fns%2Fxbl\46sa\75D\46sntz\0751\46usg\75AFQjCNGRaYt5Rt-ORLdHlBX201dXhzkBHw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2Fns%2Fxbl\46sa\75D\46sntz\0751\46usg\75AFQjCNGRaYt5Rt-ORLdHlBX201dXhzkBHw';return true;">http://www.w3.org/ns/xbl"
         xmlns:xxbl="<a href="http://orbeon.org/oxf/xml/xbl" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Forbeon.org%2Foxf%2Fxml%2Fxbl\46sa\75D\46sntz\0751\46usg\75AFQjCNEb3otbPH2r0wKjT9jLvJ_6jwg6BA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Forbeon.org%2Foxf%2Fxml%2Fxbl\46sa\75D\46sntz\0751\46usg\75AFQjCNEb3otbPH2r0wKjT9jLvJ_6jwg6BA';return true;">http://orbeon.org/oxf/xml/xbl"
         xmlns:xsl="<a href="http://www.w3.org/1999/XSL/Transform" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2F1999%2FXSL%2FTransform\46sa\75D\46sntz\0751\46usg\75AFQjCNGlnJQfHfrx1POko4fKQj_0jkFwbA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.w3.org%2F1999%2FXSL%2FTransform\46sa\75D\46sntz\0751\46usg\75AFQjCNGlnJQfHfrx1POko4fKQj_0jkFwbA';return true;">http://www.w3.org/1999/XSL/Transform"
         xmlns:oxf="<a href="http://www.orbeon.com/oxf/processors" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.orbeon.com%2Foxf%2Fprocessors\46sa\75D\46sntz\0751\46usg\75AFQjCNHUiiFySGwdM1bIDS_mg6f5SnUe1Q';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.orbeon.com%2Foxf%2Fprocessors\46sa\75D\46sntz\0751\46usg\75AFQjCNHUiiFySGwdM1bIDS_mg6f5SnUe1Q';return true;">http://www.orbeon.com/oxf/processors"
         xmlns:exf="<a href="http://www.exforms.org/exf/1-0" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.exforms.org%2Fexf%2F1-0\46sa\75D\46sntz\0751\46usg\75AFQjCNEwPVZfit48upvUmPNDFQ6uC_54oQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.exforms.org%2Fexf%2F1-0\46sa\75D\46sntz\0751\46usg\75AFQjCNEwPVZfit48upvUmPNDFQ6uC_54oQ';return true;">http://www.exforms.org/exf/1-0"
         xmlns:myxbl="<a href="http://www.my.com/myxbl" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.my.com%2Fmyxbl\46sa\75D\46sntz\0751\46usg\75AFQjCNHmmOBgyi5HDP340hquCX22XiC1iw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.my.com%2Fmyxbl\46sa\75D\46sntz\0751\46usg\75AFQjCNHmmOBgyi5HDP340hquCX22XiC1iw';return true;">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&#160;', $currency)), '.,', ',.')
                    else translate(format-number($binding, concat('#,##0&#160;', $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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Rb9bMjpyhlsJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">orbeon+un...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Rb9bMjpyhlsJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">orb...@....

--
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].
Reply | Threaded
Open this post in threaded view
|

Re: XBL or other option to format numbers in output

Alessandro  Vernet
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:
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:
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:
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&#160;', $currency)), '.,', ',.')
                    else translate(format-number($binding, concat('#,##0&#160;', $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].

--
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].

--
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