0

How may I specifiy that the field that is to hold the sum of two other fields should be able to display a value higher than $999.999.99 as dollars and cents?

The source code of the form is below.

When I test the form, I enter 999999.99 in amount_1 and it displays $999,999.99. I enter .01 in amount_2. The total_amount field displays $1.0E. I want it to display $1,000,000.00 and gives a missing or incorrect value error.

I have tried using a Text Output control, but have the same problem.

I am writing a banking application that uses Form Runner to request data from bank agents, so floating point fields are not accurate enough.

I have looked at several posts that seem related to fomatting output, but have seen none that helped. I am using the default output format for the various data types.

Thank you for your help.

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
        xmlns:exforms="http://www.exforms.org/exf/1-0"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
        xmlns:saxon="http://saxon.sf.net/"
        xmlns:sql="http://orbeon.org/oxf/xml/sql"
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<xhtml:head>
    <xhtml:title>Format Test Form</xhtml:title>
    <xforms:model id="fr-form-model">

        <!-- Main instance -->
        <xforms:instance id="fr-form-instance">
            <form>
                <section-1>
                    <amount_1/>
                    <amount_2/>
                    <total_amount/>

                </section-1>
            </form>
        </xforms:instance>

        <!-- Bindings -->
        <xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')">
            <xforms:bind id="section-1-bind" nodeset="section-1">
                <xforms:bind id="amount_1-bind" nodeset="amount_1" type="xforms:decimal" name="amount_1"/>
                <xforms:bind id="amount_2-bind" nodeset="amount_2" type="xforms:decimal" name="amount_2"/>
                <xforms:bind id="total_amount-bind" nodeset="total_amount" name="total_amount"
                             type="xforms:decimal"
                             calculate="if ($amount_1 castable as xs:double and $amount_2 castable as xs:double) then $amount_1 + $amount_2 else 123456789012345"/>

            </xforms:bind>
        </xforms:bind>

        <!-- Metadata -->
        <xforms:instance id="fr-form-metadata" xxforms:readonly="true">
            <metadata>
                <application-name>BusTravelApp</application-name>
                <form-name>FormatTestForm</form-name>
                <title xml:lang="en">Format Test Form</title>
                <description xml:lang="en"/>
                <author/>
                <logo mediatype="" filename="" size=""/>
            </metadata>
        </xforms:instance>

        <!-- Attachments -->
        <xforms:instance id="fr-form-attachments">
            <attachments>
                <css mediatype="text/css" filename="" size=""/>
                <pdf mediatype="application/pdf" filename="" size=""/>
            </attachments>
        </xforms:instance>

        <!-- All form resources -->
        <!-- Don't make readonly by default in case a service modifies the resources -->
        <xforms:instance id="fr-form-resources" xxforms:readonly="false">
            <resources>
                <resource xml:lang="en">
                    <amount_1>
                        <label>Amount 1</label>
                        <hint/>
                        <help/>
                        <alert/>
                    </amount_1>
                    <amount_2>
                        <label>Amount 2</label>
                        <hint/>
                        <help/>
                        <alert/>
                    </amount_2>
                    <total_amount>
                        <label>Total Amount</label>
                        <hint/>
                        <help/>
                        <alert/>
                    </total_amount>
                    <section-1>
                        <label>Section-1</label>
                        <help/>
                    </section-1>

                </resource>
            </resources>
        </xforms:instance>

        <!-- Utility instances for services -->
        <xforms:instance id="fr-service-request-instance" xxforms:exclude-result-prefixes="#all">
            <request/>
        </xforms:instance>

        <xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all">
            <response/>
        </xforms:instance>

    </xforms:model>
</xhtml:head>
<xhtml:body>
    <fr:view>
        <xforms:label ref="instance('fr-form-metadata')/title"/>
        <fr:body>
            <fr:section id="section-1-section" bind="section-1-bind">
                <xforms:label ref="$form-resources/section-1/label"/>
                <xforms:help ref="$form-resources/section-1/help"/>
                <fr:grid columns="3">
                    <xhtml:tr>
                        <xhtml:td>
                            <fr:currency xmlns="http://orbeon.org/oxf/xml/form-builder"
                                         xmlns:exf="http://www.exforms.org/exf/1-0"
                                         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:xbl="http://www.w3.org/ns/xbl"
                                         xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
                                         xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
                                         bind="amount_1-bind"
                                         id="amount_1-control">
                                <xforms:label ref="$form-resources/amount_1/label"/>
                                <xforms:hint ref="$form-resources/amount_1/hint"/>
                                <xforms:help ref="$form-resources/amount_1/help"/>
                                <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                            </fr:currency>

                        </xhtml:td>
                        <xhtml:td>
                            <fr:currency xmlns="http://orbeon.org/oxf/xml/form-builder"
                                         xmlns:exf="http://www.exforms.org/exf/1-0"
                                         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:xbl="http://www.w3.org/ns/xbl"
                                         xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
                                         xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
                                         bind="amount_2-bind"
                                         id="amount_2-control">
                                <xforms:label ref="$form-resources/amount_2/label"/>
                                <xforms:hint ref="$form-resources/amount_2/hint"/>
                                <xforms:help ref="$form-resources/amount_2/help"/>
                                <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                            </fr:currency>
                        </xhtml:td>
                        <xhtml:td>
                            <fr:currency xmlns="http://orbeon.org/oxf/xml/form-builder"
                                         xmlns:exf="http://www.exforms.org/exf/1-0"
                                         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:xbl="http://www.w3.org/ns/xbl"
                                         xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
                                         xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
                                         id="total_amount-control"
                                         bind="total_amount-bind">
                                <xforms:label ref="$form-resources/total_amount/label"/>
                                <xforms:hint ref="$form-resources/total_amount/hint"/>
                                <xforms:help ref="$form-resources/total_amount/help"/>
                                <xforms:alert ref="$fr-resources/detail/labels/alert"/>
                            </fr:currency>
                        </xhtml:td>
                    </xhtml:tr>
                </fr:grid>
            </fr:section>
        </fr:body>
    </fr:view>
</xhtml:body>

4

1 に答える 1

0

xforms:outputこのような値のフォーマットを使用して使用します。

<xforms:output bind="total_amount-bind" xxforms:format="format-number(., $ ###,###.##)" />

参考文献: http://wiki.orbeon.com/forms/doc/developer-guide/xforms-other-extensions#TOC-The-xxforms:format-attribute

http://www.w3schools.com/xsl/func_formatnumber.asp

于 2012-11-24T06:40:24.183 に答える