Thanks to SO for letting me know about AVT in my previous question.
I thought AVT can be applied to all attributes, but i found that it is not working for attribute id. I read W3C recommendations and come to know that AVT cannot be applied to all attributes.
Please can some one let me know if this works with Orbeon Xforms.
Sample Code(Play it in Sandbox!):
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:saxon="http://saxon.sf.net/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:exforms="http://www.exforms.org/exf/1-0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
xmlns:f="http://orbeon.org/oxf/xml/formatting"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:date="http://exslt.org/dates-and-times">
<xhtml:head>
<xhtml:title>Address Details</xhtml:title>
<xforms:model>
<xforms:instance id="address-details" xmlns="">
<form>
<address>
<address-1></address-1>
</address>
</form>
</xforms:instance>
<xforms:bind id="address-1" nodeset="instance('address-details')/address/address-1"
readonly="false()"
constraint="string-length(.) <= 15"/>
<xxforms:variable name="id-name" select="CONTROL-ID" />
</xforms:model>
</xhtml:head>
<xhtml:body>
<table>
<tr>
<td>
Address 1:
</td>
<td>
<xforms:input bind="address-1" incremental="true" id="{$id-name}">
<xforms:alert>Maximum allowed characters are 15</xforms:alert>
</xforms:input>
</td>
</tr>
</table>
</xhtml:body>
</xhtml:html>
We can see the HTML source which shows that the AVT is not interpreted.
I know that the form runner appends a dynamic name to the id value, but thats fine for me.
Please can some one let me know if this works with Orbeon Xforms or not.
Simple answer: AVTs don't work on the id attribute of XForms elements. You have to pick an id statically.
Related
I found a few questions related to my problem (Orbeon index of repeat in repeatable section, Orbeon relevant properties and Orbeon nested repeats), but I couldn't get any of them to work properly.
I define a repeatable section with a couple of questions inside and a some relevant rules. I also define some events to manage the visibility of the questions. The problem appears when I create several repeated groups. When I select one of the answers, the relevant rules and the events are launched for all the questions with the same xpath route.
So, my question is: Is there a way to manage the same events ans the same relevant rules for repeatable sections?. That is, could I define some kind of dynamic route based on the index of the section that the user is selecting at the moment and use it in the relevant rules and the events?
The complete code used for the example is below:
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude">
<xh:head>
<xh:meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<xh:title>Test_repeatable</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>Test_app</application-name>
<form-name>Test_repeatable_v1</form-name>
<title xml:lang="en">Test_repeatable</title>
<description xml:lang="en">Description of the form.</description>
<singleton>false</singleton>
</metadata>
</xf:instance>
<xf:instance id="fr-form-instance">
<form>
<Category>
<Group>
<Group-iterator>
<Question/>
<Question2/>
<Question3/>
</Group-iterator>
</Group>
</Category>
</form>
</xf:instance>
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="Category-bind" name="Category" ref="/form/Category">
<xf:bind id="Group-bind" name="Group" ref="/form/Category/Group">
<xf:bind id="Group-iterator-bind" name="Group-iterator"
ref="/form/Category/Group/Group-iterator">
<xf:bind id="Question-bind" name="Question" ref="Question" required="true()"/>
<xf:bind id="Question2-bind"
name="Question2"
readonly="false"
ref="Question2"
relevant="/form/Category/Group/Group-iterator/Question='Answer'"
required="true()"/>
<xf:bind id="Question3-bind"
name="Question3"
readonly="false"
ref="Question3"
relevant="/form/Category/Group/Group-iterator/Question='Answer2' or instance('visible')/Group/Group-iterator/Question2 != 'false' "
required="true()"/>
</xf:bind>
</xf:bind>
</xf:bind>
</xf:bind>
<xf:instance id="fr-form-attachments">
<attachments>
<css filename="" mediatype="text/css" size=""/>
<pdf filename="" mediatype="application/pdf" size=""/>
</attachments>
</xf:instance>
<xf:instance id="fr-form-resources" xxf:readonly="false">
<resources>
<resource xml:lang="en">
<Category>
<label>Category</label>
<hint/>
<alert/>
<Group>
<label>Group</label>
<hint/>
<alert/>
<Question>
<label>Question</label>
<hint/>
<alert/>
<item>
<label>Answer</label>
<hint/>
<value>Answer</value>
</item>
<item>
<label>Answer2</label>
<hint/>
<value>Answer2</value>
</item>
</Question>
<Question2>
<label>Question2</label>
<hint/>
<alert/>
</Question2>
<Question3>
<label>Question3</label>
<hint/>
<alert/>
</Question3>
</Group>
</Category>
</resource>
</resources>
</xf:instance>
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
<xf:instance xxf:readonly="true" id="Group-template">
<Group-iterator>
<Question/>
<Question2/>
<Question3/>
</Group-iterator>
</xf:instance>
<!-- Keep track of visible/hidden status -->
<xf:instance id="visible">
<visible>
<Category>0</Category>
<Group>
<Group-iterator>
<Question>false</Question>
<Question2>false</Question2>
<Question3>false</Question3>
</Group-iterator>
</Group>
</visible>
</xf:instance>
<!-- Change the visibility status for 'Question'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question-control"
ref="instance('visible')/Group/Group-iterator/Question"
value="'true'"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question-control"
ref="instance('visible')/Group/Group-iterator/Question"
value="'false'"/>
<!-- Update category showed elements count for 'Question'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question-control"
ref="instance('visible')/Category"
value="instance('visible')/Category + 1"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question-control"
ref="instance('visible')/Category"
value="instance('visible')/Category - 1"/>
<!-- Change the visibility status for 'Question2'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question2-control"
ref="instance('visible')/Group/Group-iterator/Question2"
value="'true'"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question2-control"
ref="instance('visible')/Group/Group-iterator/Question2"
value="'false'"/>
<!-- Update category showed elements count for 'Question2'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question2-control"
ref="instance('visible')/Category"
value="instance('visible')/Category + 1"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question2-control"
ref="instance('visible')/Category"
value="instance('visible')/Category - 1"/>
<!-- Change the visibility status for 'Question3'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question3-control"
ref="instance('visible')/Group/Group-iterator/Question3"
value="'true'"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question3-control"
ref="instance('visible')/Group/Group-iterator/Question3"
value="'false'"/>
<!-- Update category showed elements count for 'Question3'. -->
<xf:setvalue ev:event="xforms-enabled" observer="Question3-control"
ref="instance('visible')/Category"
value="instance('visible')/Category + 1"/>
<xf:setvalue ev:event="xforms-disabled" observer="Question3-control"
ref="instance('visible')/Category"
value="instance('visible')/Category - 1"/>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel">
<fr:section bind="Category-bind"
id="Category-control">
<xf:label mediatype="text/html"
ref="instance('fr-form-resources')/resource/Category/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/alert"/>
<fr:section bind="Group-bind"
id="Group-control"
max="100"
min="1"
repeat="content"
template="instance('Group-template')">
<xf:label mediatype="text/html"
ref="instance('fr-form-resources')/resource/Category/Group/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/Group/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/Group/alert"/>
<xh:tr>
<xh:td>
<xf:select1 appearance="full" bind="Question-bind"
id="Question-control">
<xf:label mediatype="text/html"
ref="instance('fr-form-resources')/resource/Category/Group/Question/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/Group/Question/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/Group/Question/alert"/>
<xf:itemset
ref="instance('fr-form-resources')/resource/Category/Group/Question/item">
<xf:label ref="label"/>
<xf:value ref="value"/>
<xf:hint ref="hint"/>
</xf:itemset>
</xf:select1>
</xh:td>
</xh:tr>
<xh:tr>
<xh:td>
<xf:input bind="Question2-bind"
id="Question2-control">
<xf:label mediatype="text/html"
ref="instance('fr-form-resources')/resource/Category/Group/Question2/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/Group/Question2/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/Group/Question2/alert"/>
</xf:input>
</xh:td>
</xh:tr>
<xh:tr>
<xh:td>
<xf:input bind="Question3-bind"
id="Question3-control">
<xf:label mediatype="text/html"
ref="instance('fr-form-resources')/resource/Category/Group/Question3/label"/>
<xf:hint ref="instance('fr-form-resources')/resource/Category/Group/Question3/hint"/>
<xf:alert ref="instance('fr-form-resources')/resource/Category/Group/Question3/alert"/>
</xf:input>
</xh:td>
</xh:tr>
</fr:section>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
EDIT: A little explanation of the code above.
This example has two sections, one normal and inside of it one repeatable.
Inside the repeatable section there are three questions. The first question has two answers. When I select the first answer the form runner must show the questions two and three. When the second answer is selected the runner must show only the third question. This works correctly if I only have one repeatable section.
The problem appears when I create a new repeatable section. If I select the answer one of the first question, the following questions are shown at the same time in both repeatable groups. The same when I select answer two.
So the question is: Is there a way to tell the Orbeon runner that it must apply the relevant rules only to the repeatable group where the event happens?
EDIT 2: Ok, your solution is working perfect in the case of 'Question2'.
The problem comes with Question 3. If you check the code for Question3 you can see that I try to access also another instance:
relevant="$Question='Answer2' or instance('visible')/Group/Group-iterator/Question2 != 'false' "
The 'visible' instance is not related with any control or bind, is only used for storing an internal value for the questions and is updated using xforms events, as you can see in the code below:
<xf:setvalue ev:event="xforms-enabled"
observer="Question2-control"
ref="instance('visible')/Group/Group-iterator/Question2"
value="'true'"/>
Thus, my new question is: Is there a way to store different values for different iterations of a repeatable section in a static instance and accessing them using a dynamic path (like in your first response with the $)?
If in the xf:bind for Question2 you want to refer to the value of Question in the same iteration, then just use $Question. In fact, as a rule of thumb, you can always refer to the value of another control gaga as $gaga, and trust that the right thing will happen. (At least it will in most cases.) So, your xf:bind for Question2 will become:
<xf:bind id="Question2-bind" name="Question2"
readonly="false" ref="Question2"
relevant="$Question='Answer'"
required="true()"/>
Why is it that when I set the 'oxf.xforms.cache.document' property to false in my local properties file, dynamic labels for buttons and fieldsets no longer seem to update correctly.
I am using the following xform to test this:
<xhtml:html xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms">
<xhtml:head>
<xhtml:title>Dynamic label</xhtml:title>
<xf:model id="m-default">
<xf:instance id="i-default">
<default xmlns="">
<in />
</default>
</xf:instance>
<xxf:var name="input" value="instance('i-default')/in" />
</xf:model>
</xhtml:head>
<xhtml:body>
<xhtml:h1>Dynamic label</xhtml:h1>
<xf:group ref="instance('i-default')" appearance="xxf:fieldset">
<xf:label>
<xf:output value="count(instance('i-default')[in != ''])" />
</xf:label>
<xf:input ref="$input" incremental="true">
<xf:label>
<xf:output value="'Input: '" />
</xf:label>
</xf:input>
<xhtml:div>
<xf:group ref=".[$input != '']">
<xf:trigger>
<xf:label>
<xf:output value="$input" />
</xf:label>
</xf:trigger>
</xf:group>
</xhtml:div>
</xf:group>
</xhtml:body>
When the property is set to true and I type something in the input field, the label of the fieldset will update to 1 and the button will appear with a label containing the same text as the input field. When the property is set to false the button will appear when I type something the first time, but the fieldset label will not update to 1 and any subsequent entries will not change the label on the button anymore.
Tested this with Orbeon 4.6.0.201406210117-CE.
For reference this is a bug and we have entered an issue here.
I working on a search application using XForms standards. the applications searches a small xml file that contains students data. I've written the queries using XQuery and I've tried them out. queries results are fine, very fine. but when I connect them using XForms with the instance and submissions, the presentation layer(a xf:repeat table, each raw is a student) doesn't get updated at all.
I know that the queries are valid. the presentation is good but I'm not sure.
My question could please help me make a working copy of this application.
the Model is as follow
<xf:model>
<xf:action ev:event="xforms-ready">
<xf:send submission="load-data"/>
</xf:action>
<xf:instance xmlns="" id="studInstance">
<students>
<student>
<idStudent/>
<Name/>
<LastName/>
<Address/>
</student>
</students>
</xf:instance>
<xf:instance xmlns="" id="search">
<parameters>
<query/>
<field>Name</field>
</parameters>
</xf:instance>
<xf:submission id="load-data" method="get" serialization="none" action="modules/load.xql" replace="instance" instance="studInstance">
<xf:message ev:event="xforms-submit-error" level="ephemeral">Load operation failed </xf:message>
<xf:message ev:event="xforms-submit-done" level="ephemeral">Load operation Succeeded </xf:message>
</xf:submission>
<xf:submission id="search" action="modules/search.xql" method="post" serialization="none" ref="instance('search')" targetref="instance('studInstance')" replace="instance">
<xf:message ev:event="xforms-submit-error" level="ephemeral">Search operation failed </xf:message>
</xf:submission>
</xf:model>
the result would be bind-ed to repeat section here:
<xf:group>
<xf:repeat instance="studInstance" nodeset="/students/student">
<tr>
<td>
<xf:output ref="idStudent"/>
</td>
<td>
<xf:output ref="Name"/>
</td>
<td>
<xf:output ref="LastName"/>
</td>
<td>
<xf:output ref="Address"/>
</td>
</tr>
</xf:repeat>
</xf:group>
So what's wrong with this code!
The attribute instance has no meaning in a xf:repeat. The correct way of doing what you want is using the instance function inside your XPath:
<xf:repeat nodeset="instance(studInstance)/student">
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>
Use xforms:output and use formatting the value something like this.
<xforms:output bind="total_amount-bind" xxforms:format="format-number(., $ ###,###.##)" />
References:
http://wiki.orbeon.com/forms/doc/developer-guide/xforms-other-extensions#TOC-The-xxforms:format-attribute
http://www.w3schools.com/xsl/func_formatnumber.asp
I've got a problem and hope it's only my lack of experience in XForms. I need to create checkbox item for data that is defined as an enumeration 'Yes'/'No'. Basically it's just boolean value but with another pair of values. What I've already been able to do is something that basically works but need extra data node in model:
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:f="http://orbeon.org/oxf/xml/formatting"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<xhtml:head>
<xforms:model xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema" id="main-model">
<xforms:instance id="instance">
<main>
<Boolean>true</Boolean>
<YesNo>Yes</YesNo>
</main>
</xforms:instance>
<xforms:bind ref="Boolean" type="xsd:boolean" />
<xforms:bind ref="YesNo" constraint=". = 'Yes' or . = 'No'" />
</xforms:model>
</xhtml:head>
<xhtml:body>
<xforms:input ref="instance('instance')/Boolean">
<xforms:label>Boolean: </xforms:label>
<xforms:action ev:event="xforms-value-changed">
<xforms:setvalue ref="instance('instance')/YesNo" value="if ( instance('instance')/Boolean = 'true' ) then 'Yes' else 'No'" />
</xforms:action>
</xforms:input>
<br/>
<xforms:output ref="instance('instance')/Boolean">
<xforms:label>Boolean:</xforms:label>
</xforms:output>
<br/>
<br/>
<xforms:select ref="instance('instance')/YesNo" appearance="full">
<xforms:label>Yes/No: </xforms:label>
<xforms:item>
<xforms:label></xforms:label>
<xforms:value>Yes</xforms:value>
</xforms:item>
<xforms:action ev:event="xforms-value-changed">
<xforms:setvalue ref="instance('instance')/YesNo" value="if ( instance('instance')/YesNo = 'Yes' ) then 'Yes' else 'No'" />
</xforms:action>
</xforms:select>
<br/>
<xforms:output ref="instance('instance')/YesNo">
<xforms:label>Yes/No:</xforms:label>
</xforms:output>
</xhtml:body>
</xhtml:html>
This example contains two possible solutions:
First is standard boolean checkbox bound to boolean instance node with an action that set 'Yes'/'No' value for the second node. This solution works well but requires second data node which I cannot create due to schema (in the example above I could generally create second instance to store this value but in real project these checkboxes are in repeat block and I would have to create extra table of values for this which seems to be to much complicated),
Second is select item with one and only value 'Yes' and action that tries to set 'No' value when empty value is set (unselected item). Unfortunatelly when this item is deselected it's unable to select it again (deselects automatically). Has any of you solution for such an issue?
Thanks in advance
Hope this solves your problem..
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:f="http://orbeon.org/oxf/xml/formatting"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<xhtml:head>
<xforms:model xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema" id="main-model">
<xforms:instance id="instance">
<main>
<Boolean value="true">Yes</Boolean>
</main>
</xforms:instance>
<xforms:bind ref="Boolean/#value" type="xforms:boolean" readonly="false()" />
<xforms:bind ref="Boolean" calculate="if(#value=true()) then 'Yes' else 'No'" readonly="false()" />
</xforms:model>
</xhtml:head>
<xhtml:body>
<xforms:input ref="instance('instance')/Boolean/#value">
<xforms:label>Boolean: </xforms:label>
</xforms:input>
<br/>
<xforms:output ref="instance('instance')/Boolean">
<xforms:label>Boolean:</xforms:label>
</xforms:output>
<br/>
<xforms:output ref="instance('instance')/Boolean/#value">
<xforms:label>Boolean/#value:</xforms:label>
</xforms:output>
<br/>
<br/>
</xhtml:body>
</xhtml:html>
In case if you are not allowed to use attributes to your xml node, then have the boolean values while user working on the form. On submit event, you can set the boolean values to Yes or No and push the data to external system.