Thread: [Xsltforms-support] No support for xsi:nil
Brought to you by:
alain-couthures
From: Steve B. <ste...@co...> - 2011-06-21 19:15:37
|
Hello I am trying to get a sample form working which should allow numeric inputs that also allow nulls. The model looks like this: <xf:model> <xf:instance id="i0" src="formmodel/99"> <XFAnswers submitUri="formmodel/99"> <XFAnswer questionUserCode="firstNames"><Value>Fred</Value></XFAnswer> <XFAnswer questionUserCode="numberOfSiblings"><Value xsi:nil="true"></Value></XFAnswer> <XFAnswer questionUserCode="weightInKg"><Value xsi:nil="true"></Value></XFAnswer> </XFAnswers> </xf:instance> <xf:submission id="s01" method="put"> <xf:resource value="//XFAnswers/@submitUri"/> <xf:message ev:event="xforms-submit-error">A submission error (<output value="event('error-type')"/>) occurred.</xf:message> </xf:submission> <xf:bind nodeset="//XFAnswer[@questionUserCode='firstNames']/Value" type="xs:string" id="firstNames"/> <xf:bind nodeset="//XFAnswer[@questionUserCode='numberOfSiblings']/Value" type="xs:long" id="numberOfSiblings"/> <xf:bind nodeset="//XFAnswer[@questionUserCode='weightInKg']/Value" type="xs:decimal" id="weightInKg"/> </xf:model> Submission errors occur until the controls bound to the numeric types have numeric values, despite the model starting with nil attributes. I'm wondering, in the method XFInstance.prototype.validate_, should the "notvalid" property really be set for bound nodes when schema validation fails - if the field is empty and nillable? Regards Steve Brown Senior Developer Corelogic Limited Email: ste...@co... <mailto:ste...@bt...> |
From: Alain C. <ala...@ag...> - 2011-06-22 20:01:07
|
Hello Steve, As you suggested, I have modified the setting of the "notvalid" property in the XFInstance.prototype.validate_() method to support xsi:nil. Please have a look at rev. 508 It is my understanding that xsi:nil will not allow any value at all. For allowing both empty values and typed values, you have to use xforms types instead of xsd types. Thank you for your feedbacks! -Alain Le 21/06/2011 21:03, Steve Brown a écrit : > > Hello > > I am trying to get a sample form working which should allow numeric > inputs that also allow nulls. > > The model looks like this: > > <xf:model> > > <xf:instance id="i0" src="formmodel/99"> > > <XFAnswers submitUri="formmodel/99"> > > <XFAnswer questionUserCode="firstNames"><Value>Fred</Value></XFAnswer> > > <XFAnswer questionUserCode="numberOfSiblings"><Value > xsi:nil="true"></Value></XFAnswer> > > <XFAnswer questionUserCode="weightInKg"><Value > xsi:nil="true"></Value></XFAnswer> > > </XFAnswers> > > </xf:instance> > > <xf:submission id="s01" method="put"> > > <xf:resource value="//XFAnswers/@submitUri"/> > > <xf:message ev:event="xforms-submit-error">A submission error (<output > value="event('error-type')"/>) occurred.</xf:message> > > </xf:submission> > > <xf:bind nodeset="//XFAnswer[@questionUserCode='firstNames']/Value" > type="xs:string" id="firstNames"/> > > <xf:bind > nodeset="//XFAnswer[@questionUserCode='numberOfSiblings']/Value" > type="xs:long" id="numberOfSiblings"/> > > <xf:bind nodeset="//XFAnswer[@questionUserCode='weightInKg']/Value" > type="xs:decimal" id="weightInKg"/> > > </xf:model> > > Submission errors occur until the controls bound to the numeric types > have numeric values, despite the model starting with nil attributes. > I'm wondering, in the method > > XFInstance.prototype.validate_, should the "notvalid" property really > be set for bound nodes when schema validation fails - if the field is > empty and nillable? > > Regards > > *Steve Brown* > > Senior Developer > > Corelogic Limited > > Email: ste...@co... <mailto:ste...@bt...> > > > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically advanced content > authoring tool. Experience the power of Track Changes, Inline Image > Editing and ensure content is compliant with Accessibility Checking. > http://p.sf.net/sfu/ephox-dev2dev > > > _______________________________________________ > Xsltforms-support mailing list > Xsl...@li... > https://lists.sourceforge.net/lists/listinfo/xsltforms-support |
From: Steve B. <ste...@co...> - 2011-06-23 15:00:20
|
Hi Alain Many thanks for your swift response. Your suggestion to use xforms types has given me all I needed so I didn't initially try using xsd types with xsi:nil and thereby test your code. When I did test your fix it didn't seem to work as I expected. My understanding is that a value of "" and xsi:nil means that validation against the schema type should not happen: so the code should look like this - this.setProperty_(node, "notvalid", !Core.getBoolMeta(node, "notrelevant") && !(!(Core.getBoolMeta(node, "required") && (!value || value == "")) && (!schtyp || (value == "" && Core.getNil(node)) || schtyp.validate(value)) && (!bind.constraint || booleanValue(bind.constraint.evaluate(ctx))))); However, I see now that xsi:nil could never be made to do what I was trying to do. To work, the script would have to be inserting and removing the xsi:nil attributes from elements depending on whether they are empty or not. As you say, only xforms types should be used! Steve Steve Brown Senior Developer Corelogic Limited Email: ste...@co... <mailto:ste...@bt...> From: Alain Couthures [mailto:ala...@ag...] Sent: 22 June 2011 21:04 To: Steve Brown Cc: xsl...@li... Subject: Re: [Xsltforms-support] No support for xsi:nil Hello Steve, As you suggested, I have modified the setting of the "notvalid" property in the XFInstance.prototype.validate_() method to support xsi:nil. Please have a look at rev. 508 It is my understanding that xsi:nil will not allow any value at all. For allowing both empty values and typed values, you have to use xforms types instead of xsd types. Thank you for your feedbacks! -Alain Le 21/06/2011 21:03, Steve Brown a écrit : Hello I am trying to get a sample form working which should allow numeric inputs that also allow nulls. The model looks like this: <xf:model> <xf:instance id="i0" src="formmodel/99"> <XFAnswers submitUri="formmodel/99"> <XFAnswer questionUserCode="firstNames"><Value>Fred</Value></XFAnswer> <XFAnswer questionUserCode="numberOfSiblings"><Value xsi:nil="true"></Value></XFAnswer> <XFAnswer questionUserCode="weightInKg"><Value xsi:nil="true"></Value></XFAnswer> </XFAnswers> </xf:instance> <xf:submission id="s01" method="put"> <xf:resource value="//XFAnswers/@submitUri"/> <xf:message ev:event="xforms-submit-error">A submission error (<output value="event('error-type')"/>) occurred.</xf:message> </xf:submission> <xf:bind nodeset="//XFAnswer[@questionUserCode='firstNames']/Value" type="xs:string" id="firstNames"/> <xf:bind nodeset="//XFAnswer[@questionUserCode='numberOfSiblings']/Value" type="xs:long" id="numberOfSiblings"/> <xf:bind nodeset="//XFAnswer[@questionUserCode='weightInKg']/Value" type="xs:decimal" id="weightInKg"/> </xf:model> Submission errors occur until the controls bound to the numeric types have numeric values, despite the model starting with nil attributes. I'm wondering, in the method XFInstance.prototype.validate_, should the "notvalid" property really be set for bound nodes when schema validation fails - if the field is empty and nillable? Regards Steve Brown Senior Developer Corelogic Limited Email: ste...@co... <mailto:ste...@bt...> ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ Xsltforms-support mailing list Xsl...@li... https://lists.sourceforge.net/lists/listinfo/xsltforms-support |