| <xforms:model id=“payinfo“> <xforms:submission action="http://www.example.com/orderform.php" method="post"/> <xforms:instance xmlns=""> <paymentinfo> <method></method> <cardtype></cardtype> <cardnumber></cardnumber> <expdate></expdate> </paymentinfo> </xforms:instance> <xforms:bind ref="paymentinfo" type="ccnumber"/> <xsd:schema> <xsd:simpleType name="ccnumber"> <xsd:restriction base="xsd:string"> <xsd:pattern value="\d{14,18}"/> </xsd:restriction> </xsd:simpleType> </xsd:schema> </xforms:model> 2、强制输入 ... </xsd:schema> <xforms:bind ref="paymentinfo/cardnumber" required="true()" type="ccnumber"/> </xforms:model> ...
3、带条件的强制输入 如只有当用户选择信用卡支付时才要求输入信用卡号: ... </xsd:schema> <xforms:bind ref="paymentinfo/cardnumber" relevant="paymentinfo/method = 'cc'" required="true()" type="ccnumber"/> </xforms:model>
4、只读字段 如“单价”字段不允许修改 ... </order> </xforms:instance> <xforms:bind ref="order/soaps/item/unitprice" readonly="true()"/> </xforms:model> ...
5、计算字段 如“总价”=数量 * 单价: ... </order> </xforms:instance> <xforms:bind ref="order/soaps/item/unitprice" readOnly="true()"/> <xforms:bind ref="order/soaps/item/totalprice" calculate="../qty * ../unitprice"/> </xforms:model> ...
6、bind元素的其它属性 constraint:该属性设置任意的约束。比如,开发人员可以限制某个节点比另一个小。 maxOccurs 和 minOccurs:这两个属性确定表单中可以出现多少个项。 p3ptype:该属性把一个节点绑定到用户私有工作文件中的信息。
|