- From: michael odling-smee <mike.odlingsmee@gmail.com>
- Date: Wed, 21 Jun 2017 10:26:44 +0100
- To: XForms <public-xformsusers@w3.org>
- Cc: Steven Pemberton <steven.pemberton@cwi.nl>
- Message-ID: <CAJEDUV=njvFEJN64pcsvdo+LV4LKQ_9r6CWFt1J1ctNfyF=-2g@mail.gmail.com>
I think this is a great suggestion - the more that can be specified via MIPs on binds the better I feel. Further to Mark's suggestion we often encounter a requirement to provide different alert messages depending on the validation issue that has been encountered. This is a feature supported by Orbeon. To do this Orbeon has a nested <xf:constraint/> elements, e.g. <xf:bind id="NumericField-bind" ref="NumericField" name="NumericField" type="xs:decimal" required="true()"> <xf:constraint id="constraint-3-constraint" value=". > 10" level="error"/> <xf:constraint id="constraint-4-constraint" value=". < 100" level="error"/> </xf:bind> ..... and then the following on the control which points to different messages <fr:number xmlns="http://orbeon.org/oxf/xml/form-builder" xmlns:xxbl=" http://orbeon.org/oxf/xml/xbl" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" id="NumericField-control" bind="NumericField-bind"> <xf:label ref="$form-resources/NumericField/label"/> <xf:hint ref="$form-resources/NumericField/hint"/> <xf:alert ref="$form-resources/NumericField/alert[1]" validation="constraint-3-constraint"/> <xf:alert ref="$form-resources/NumericField/alert[2]" validation="constraint-4-constraint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </fr:number> Without wishing to dilute the discussion, I am not sure (but maybe wrong) that the specification makes the interaction between @required and @constraint clear. For instance if I have an integer field that can be blank, but if provided should be greater than 10 do I write: <xf:bind ref="SomeInterger" type="xf:integer" required="false()" constraint=". > 10"/> or (as seems to be required by XSLTForms) <xf:bind ref="SomeInterger" type="xf:integer" required="false()" constraint=". = '' or . > 10"/> which allows for a blank value in the constraint. I would have thought it best to make sure there is no coupling between the two. Kind regards, Mike On 21 June 2017 at 09:57, Seaborne, Mark John <m.seaborne.10@aberdeen.ac.uk> wrote: > Hello Steven and co, > > Would something like this by okay too: > > <bind ref="age" type="integer"> > <alert level=“subtle”><output ref=“longwinded-error-report/ > en-gb”/></alert> > <alert level=“in-your-face”><output ref=“pithy-error-report/en-gb” > /></alert> > </bind> > > Hint and help too? > > Best wishes > > Mark > > P.S. I’ve had severe depression for a long time, but a change of > medication and better support seems to be helping and I’m finding that I am > suddenly more interested in the world around me again :) > > Still using XForms (XSLTForms) in the wild, probably not very effectively, > but hey ho. Here is an example: http://www.aocarchaeologygroup.uk. > wizzdns.com/darkAgeScot/ > > I will try to pay more attention and maybe feel up to joining in again in > the coming weeks. > > > > On 21 Jun 2017, at 08:51, Steven Pemberton <steven.pemberton@cwi.nl> > wrote: > > > > It seems to me that the Alert text of an Alert on a control really > belongs > > with the data in most cases. As it currently is, the message and the > > condition are far apart. > > > > Therefore a proposal. > > > > ==== > > The Alert Property > > > > This property associates an alert message with a constraint or type model > > binding. > > > > Computed Expression: Yes. > > > > Legal Values: Any string expression. > > > > Default Value: none. > > > > Inheritance Rules: does not inherit. > > > > Description > > > > This associates a message expression with a type or constraint property > of > > a node. If a control is bound to the node, and the node is non-valid as a > > result of the type requirements or constraint, then the associated > message > > is evaluated, and displayed as if a part of an <code>alert</code> element > > on the control. > > > > Examples > > > > <bind ref="age" type="integer" alert="'Must be a whole number'"/> > > <bind ref="age" constraint=". >= 0" alert="'Must be greater than > > zero'"/> > > > > <bind ref="wish" constraint="count(../wish) < 4" alert="'You can't > have > > more than 3 wishes'"/> > > > > <bind ref="card" type="card-number" constraint="cardnumber(.)" > > alert="'Not a valid card number'"/> > > > > <bind ref="card" type="card-number" constraint="cardnumber(.)" > > alert="instance('messages')/cardnumber"/> > > > > <bind ref="pin-code" constraint="matches(., '^\d{4}$')" alert="'must be 4 > > digits'"/> > > > > ==== > > > > Steven > > > >
Received on Wednesday, 21 June 2017 10:26:52 UTC