Re: [Xsltforms-support] [PATCH] No usefull message for non-existent bind-ids
Brought to you by:
alain-couthures
From: Kostis A. <ank...@gm...> - 2010-04-08 00:58:12
|
After searching through the specs, i realized that my patch in function Binding.evaluate() would case the engine to scream even for non-existent bidnings on actions, which it is not correct(!), according to Xforms.1.1-chapter 4.7, see: * http://www.w3.org/TR/xforms11/#idref-resolve * http://www.agencexml.com/xforms-tests/testsuite/XForms1.1/Edition1/Chapt04/4.7/4.7.a.xhtml Nevertheless, the problem is very annoying when building xforms because is difficult to debug typos, particularly when merging from different forms. The proper behavior would be to issue 'xforms-binding-exceptions', asd spec'ed by XForms1.1 chapter 4.5.1 Additionaly i found that there is another category of annoying fail-to-report binding problems. These are when a 'bind', 'ref', 'nodeset' and 'value' IDERF attributes are themselfs the empty-string ('') or absent altogether. These problems cannot be detected from within Binding.evaluate() since there is no binding object to begin with! The problem is demonstrated with the 'emptyBindings.xml' xforms below. Ideally, i would like to have a solution that gathers all these errors and reports them at once on model-construction with a single xforms-binding-exception, or afterwards, with some alert with a descriptive messages facilitating pin-pointing the error (since i have managed to build a formthat these errors were not detected from the start) Yet this check cannnot happen inside Binding.evaluate() but must be separate for * XFControl, * XFCoreElement, and * XFElement. In a summury, i'm thinking that it may be necessary to add 3 functions, one per each super-class, namely "evaluateBindings()" with different arguments each (3, 1, 1 respectively) and they would perform the various sanity checks before invoking this.binding.evaluate(). Their behavior on these 2 error categories would be different depending on whether the model has been constructed or not. Am i thinking along the correct lines, Alain? Regards, Kostis file: emptyBindings.xml ------------------- <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="xsltforms/xsltforms.xsl" encoding="UTF-8" type="text/xsl"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.w3.org/2002/xforms http://www.w3.org/MarkUp/Forms/2007/XForms-11-Schema.xsd " > <head> <title>Control with Empty bind-id</title> <xf:model> <xf:instance> <root /> </xf:instance> <xf:bind id="bind-with-no-nodeset"/> </xf:model> </head> <body> <xf:output id="should-not-fail-1" bind="bind-with-no-nodeset" /> <xf:repeat id="should-not-fail-3" bind="bind-with-no-nodeset" /> <xf:select1 id="should-not-fail-2" ref="/." > <xf:itemset bind="bind-with-no-nodeset" /> </xf:select1> The control's empty-binding below fail with un-helpful err-messages. <xf:output /> <xf:output ref="" /> <xf:output value="" /> <xf:select1 > <xf:itemset /> </xf:select1> <xf:select1 > <xf:itemset nodeset="" /> </xf:select1> <xf:select > <xf:itemset /> </xf:select> <xf:select > <xf:itemset nodeset="" /> </xf:select> <xf:repeat /> <xf:repeat nodeset="" /> <xf:group /> <xf:group ref="" /> <xf:label /> <xf:label ref="" /> </body> </html> On Thu, Apr 8, 2010 at 1:05 AM, Kostis Anagnostopoulos <ank...@gm...> wrote: > When a control's 'bind' attrribute refers to an xf:bind that does not exist, > the javascript just fails with Null-Pointer message on browser console > instead of reporting the bad bind-id. > > Reported against rev383, all browsers. > > The simple xform below reproduces the problem, and > the following patch just issues a useful alert-window for each > non-existent bind-id: > > Regards, > Kostis > > file: nonExistentBindId.xml: > ------------------ > <?xml version="1.0" encoding="UTF-8"?> > <?xml-stylesheet href="xsltforms/xsltforms.xsl" encoding="UTF-8" > type="text/xsl"?> > <html > xmlns="http://www.w3.org/1999/xhtml" > xmlns:xf="http://www.w3.org/2002/xforms" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=" > http://www.w3.org/2002/xforms > http://www.w3.org/MarkUp/Forms/2007/XForms-11-Schema.xsd > " >> > <head> > <title>Control with non-existent bind-id</title> > > </head> > > <body> > The output control's binding below silently fails > (with an un-helpful null-pointer err-message visible only on the > browser's console). > <xf:output bind="missing-bind-id" /> > <xf:output bind="missing-bind-id2" /> > </body> > </html> > > > file: nonExistentBindId.diff > ---------------- > Index: src/js/main/Binding.js.xml > =================================================================== > --- src/js/main/Binding.js.xml (revision 383) > +++ src/js/main/Binding.js.xml (working copy) > @@ -48,7 +48,14 @@ > var result = null; > if (this.bind) { > if (typeof this.bind == "string") { > - this.bind = $(this.bind).xfElement; > + var idel = $(this.bind); > + if (!idel) { > + alert("Non-Existent bind-id: "+this.bind); > + > + // Do not fail here, to search for more missing ids. > + return ''; > + } > + this.bind = idel.xfElement; > } > result = this.bind.nodes; > copyArray(this.bind.depsNodes, depsNodes); > |