我正在开发XForm表单设计。我目前的表格看起来像这样:
<xforms:model>
<xforms:instance id="PhoneCallsSimple2" xmlns="">
<request>
<criterias relation="AND">
<criterias relation="OR">
<criteria name="CritCallStartDateLower" operator="GreaterOrEqual" model="CallStartDate" gui_display="From date"/>
<criteria name="CritCallStartDateUpper" operator="LessOrEqual" model="CallStartDate" gui_display="To date"/>
</criterias>
<criteria name="CritCallCustomerID" operator="Equal" model="CustomerID" gui_display="Customer ID"/>
<criteria name="CritCallCustomerLastName" operator="BeginWith" model="CustomerLastName" gui_display="Customer LastName"/>
</criterias>
</request>
</xforms:instance>
<xforms:bind id="bindCallStartDateLower" required="true()" type="xforms:date" nodeset="/request/criterias/criterias/criteria[@name='CritCallStartDateLower']"/>
<xforms:bind id="bindCallStartDateUpper" required="true()" type="xforms:date" nodeset="/request/criterias/criterias/criteria[@name='CritCallStartDateUpper']" constraint="(days-from-date(.) >= days-from-date(/request/criterias/criterias/criteria[@name='CritCallStartDateLower']))"/>
<xforms:bind id="bindCallCustomerID" required="false()" type="xforms:positiveInteger" nodeset="/request/criterias/criteria[@name='CritCallCustomerID']"/>
<xforms:bind id="bindCallCustomerLastName" required="false()" type="xforms:string" nodeset="/request/criterias/criteria[@name='CritCallCustomerLastName']"/>
<xforms:submission id="search" ref="/request" replace="none"/>
<xforms:submission id="order" ref="/request" replace="none"/>
<xforms:setvalue ev:event="xforms-model-construct-done" ref="/request/criterias/criterias/criteria[@name='CritCallStartDateLower']" value="days-to-date(days-from-date(local-date()) - 182) "/>
<xforms:setvalue ev:event="xforms-model-construct-done" ref="/request/criterias/criterias/criteria[@name='CritCallStartDateUpper']" value="days-to-date(days-from-date(local-date())) "/>
</xforms:model>
提交表单时,会将值添加到标准中,如下所示:
<criterias relation="AND">
<criterias relation="OR">
<criteria name="CritCallStartDateLower" operator="GreaterOrEqual" model="CallStartDate" gui_display="From date">value1</criteria>
<criteria name="CritCallStartDateUpper" operator="LessOrEqual" model="CallStartDate" gui_display="To date">value2</criteria>
</criterias>
<criteria name="CritCallCustomerID" operator="Equal" model="CustomerID" gui_display="Customer ID">value3</criteria>
<criteria name="CritCallCustomerLastName" operator="BeginWith" model="CustomerLastName" gui_display="Customer LastName"/>
</criterias>
我需要做的是编写一个xform,将值绑定到条件中的属性或子项。例如:
<criterias relation="AND">
<criterias relation="OR">
<criteria name="CritCallStartDateLower" operator="GreaterOrEqual" model="CallStartDate" gui_display="From date" value="value1"></criteria>
<criteria name="CritCallStartDateUpper" operator="LessOrEqual" model="CallStartDate" gui_display="To date"><value>value2<value></criteria>
</criterias>
<criteria name="CritCallCustomerID" operator="Equal" model="CustomerID" gui_display="Customer ID"></criteria>
<criteria name="CritCallCustomerLastName" operator="BeginWith" model="CustomerLastName" gui_display="Customer LastName"/>
</criterias>
任何帮助将不胜感激,谢谢!
答案 0 :(得分:1)
您可以使用set-value
两次,一次用于属性,另一次用于元素。如果找不到属性或值,则不会发生任何事情。
<xforms:setvalue ev:event="xforms-model-construct-done" ref="/request/criterias/criterias/criteria[@name='CritCallStartDateUpper']/@value" value="here is the new value"/>
<xforms:setvalue ev:event="xforms-model-construct-done" ref="/request/criterias/criterias/criteria[@name='CritCallStartDateUpper']/value" value="here is the new value"/>