Hi,
The rec doesn't seem very clear in that case either, but I find the current behavior surprising. Let's consider the following form: <?xml version="1.0"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:i="http://ns/xmlfr.org/example" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <head> <title>Constraint and required</title> <xforms:model id="default"> <xforms:instance> <i:instance> <i:startDate/> <i:endDate/> </i:instance> </xforms:instance> <xforms:bind nodeset="i:startDate" required="true()" type="xs:date"/> <xforms:bind nodeset="i:endDate" type="xs:date" required="false()" constraint=". >= ../i:startDate"/> <xforms:submission id="mySubmit" action="" method="put"/> </xforms:model> </head> <body> <xforms:input ref="i:startDate"> <xforms:label>Start Date:</xforms:label> </xforms:input> <br/> <xforms:input ref="i:endDate"> <xforms:label>End Date: </xforms:label> </xforms:input> </body> </html> When you enter a start date, the end date is considered invalid if it is empty. This is because the contraint is not met. This behavior is not very coherent with the case where your model is simply: <xforms:model id="default"> <xforms:instance> <i:instance> <i:startDate/> <i:endDate/> </i:instance> </xforms:instance> <xforms:bind nodeset="i:startDate" required="true()" type="xs:date"/> <xforms:bind nodeset="i:endDate" type="xs:date" required="false()"/> <xforms:submission id="mySubmit" action="" method="put"/> </xforms:model> In that case, empty end dates are allowed even though the empty string isn't a valid date which means that required="false()" "switches" off type validation for empty values. I would expect that required="false()" switches constraint validation off for empty values like it switches type validation. Of course, that's just my interpretation and, again, the spec doesn't seem to mention that. Thanks, Eric -- GPG-PGP: 2A528005 Le premier annuaire des apiculteurs 100% XML! http://apiculteurs.info/ ------------------------------------------------------------------------ Eric van der Vlist http://xmlfr.org http://dyomedea.com (ISO) RELAX NG ISBN:0-596-00421-4 http://oreilly.com/catalog/relax (W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema ------------------------------------------------------------------------ -- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws signature.asc (196 bytes) Download Attachment |
Administrator
|
Eric,
> The rec doesn't seem very clear in that case either, but I find the > current behavior surprising. > > Let's consider the following form: > > <?xml version="1.0"?> > <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" > xmlns:i="http://ns/xmlfr.org/example" xmlns:xs="http://www.w3.org/2001/XMLSchema"> > <head> > <title>Constraint and required</title> > > <xforms:model id="default"> > <xforms:instance> > <i:instance> > <i:startDate/> > <i:endDate/> > </i:instance> > </xforms:instance> > <xforms:bind nodeset="i:startDate" required="true()" type="xs:date"/> > <xforms:bind nodeset="i:endDate" type="xs:date" required="false()" > constraint=". >= ../i:startDate"/> > <xforms:submission id="mySubmit" action="" method="put"/> > </xforms:model> > > </head> > > <body> > <xforms:input ref="i:startDate"> > <xforms:label>Start Date:</xforms:label> > </xforms:input> > <br/> > <xforms:input ref="i:endDate"> > <xforms:label>End Date: </xforms:label> > </xforms:input> > > </body> > </html> > > When you enter a start date, the end date is considered invalid if it is > empty. This is because the contraint is not met. > > This behavior is not very coherent with the case where your model is > simply: > > <xforms:model id="default"> > <xforms:instance> > <i:instance> > <i:startDate/> > <i:endDate/> > </i:instance> > </xforms:instance> > <xforms:bind nodeset="i:startDate" required="true()" type="xs:date"/> > <xforms:bind nodeset="i:endDate" type="xs:date" required="false()"/> > <xforms:submission id="mySubmit" action="" method="put"/> > </xforms:model> > > In that case, empty end dates are allowed even though the empty string > isn't a valid date which means that required="false()" "switches" off > type validation for empty values. > > I would expect that required="false()" switches constraint validation > off for empty values like it switches type validation. > > Of course, that's just my interpretation and, again, the spec doesn't > seem to mention that. I entered a bug for this: http://forge.objectweb.org/tracker/index.php?func=detail&aid=306421&group_id=168&atid=350207 The intent of the specification is that validity and required-ness are completely orthogonal. A blank xs:date is in fact always invalid, even if it is optional. In XForms 1.1, the Working Group is introducing datatypes such as xforms:date that allow blank values in addition to the lexical values allowed by the XML Schema type. This way you will be able to write: <xforms:bind nodeset="i:endDate" type="xforms:date" required="true()"/> -Erik -- Orbeon Forms - XForms Everywhere http://www.orbeon.com/blog/ -- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |