Hi, I have an issue with xforms:bind. I need to do an
xforms:bind giving its type as well as a constraint. My requirement is that the
constraint should be evaluated only if there is some value in the input. For eg: I have 2 binds as : <xforms:bind
nodeset="instance('INSTANCE')/DOB/DD" type="xforms:integer"
constraint=". castable as xs:integer and .>=1 and
31>=."></xforms:bind> <xforms:bind
nodeset="instance('INSTANCE')/InsPeriod/YYYY"
type="xforms:string" constraint="string-length(.)>=4 and
4>=string-length(.) "></xforms:bind> In both cases, when the form is
first loaded, it shows exclamation mark indicating validation error. My
requirement is that these fields should be validated only if there is some
value in it. How can I achieve this? Please help. This is urgent. Thanks in advance Jency -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Hi Jency,
> <xforms:bind nodeset="instance('INSTANCE')/DOB/DD" > type="xforms:integer" constraint=". castable as xs:integer and > .>=1 and 31>=."></xforms:bind> > <xforms:bind nodeset="instance('INSTANCE')/InsPeriod/YYYY" > type="xforms:string" constraint="string-length(.)>=4 and > 4>=string-length(.) "></xforms:bind> > In both cases, when the form is first loaded, it shows exclamation > mark indicating validation error. My requirement is that these fields > should be validated only if there is some value in it. How can I > achieve this? A quick (may not the best) solution could be to rewrite the constraint clause using a if statement. If the element content is '', then the constraint is true(), else the test you already wrote should be relevant: <xforms:bind nodeset="instance('INSTANCE')/DOB/DD" type="xforms:integer" constraint="if (. eq '') then true() else (. castable as xs:integer and .>=1 and 31>=.)" /> HTH florian -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Thanks Florian. It works
-----Original Message----- From: Florian Schmitt [mailto:[hidden email]] Sent: Monday, April 28, 2008 4:40 PM To: [hidden email] Subject: [ops-users] Re: constraint in xforms:bind when value is empty Hi Jency, > <xforms:bind nodeset="instance('INSTANCE')/DOB/DD" > type="xforms:integer" constraint=". castable as xs:integer and > .>=1 and 31>=."></xforms:bind> > <xforms:bind nodeset="instance('INSTANCE')/InsPeriod/YYYY" > type="xforms:string" constraint="string-length(.)>=4 and > 4>=string-length(.) "></xforms:bind> > In both cases, when the form is first loaded, it shows exclamation > mark indicating validation error. My requirement is that these fields > should be validated only if there is some value in it. How can I > achieve this? A quick (may not the best) solution could be to rewrite the constraint clause using a if statement. If the element content is '', then the constraint is true(), else the test you already wrote should be relevant: <xforms:bind nodeset="instance('INSTANCE')/DOB/DD" type="xforms:integer" constraint="if (. eq '') then true() else (. castable as xs:integer and .>=1 and 31>=.)" /> HTH florian -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Free forum by Nabble | Edit this page |