- From: Mark Birbeck <mark.birbeck@webbackplane.com>
- Date: Thu, 6 Aug 2009 16:42:26 +0200
- To: John Boyer <boyerj@ca.ibm.com>
- Cc: adam.flinton@nhs.net, "www-forms@w3.org" <www-forms@w3.org>
Hi John, I was careful to say "you always need a nodeset" rather than "you always need @nodeset" for exactly the reasons that you said -- that @nodeset is optional. I was just trying to emphasise that you need to bind to something, and I thought I'd confuse the issue if I mentioned nested binds. However, I forgot all about the evaluation context for a top-level bind being the first instance/node of the containing model, and that, as you rightly point out, explains why Chiba was giving Adam some results when he had @calculate with no @nodeset. So it seems I couldn't get away with not mentioning nested binds after all. :) Thanks for the much-needed clarification! Regards, Mark On Thu, Aug 6, 2009 at 4:27 PM, John Boyer<boyerj@ca.ibm.com> wrote: > > Just to clarify for archival purposes, when Mark said you always need a bind > nodeset even for calculate, that's not exactly true. You always need to > have a node to which you are attaching the model item property, which is > what Mark is explaining. > > The nodeset binding on xf:bind is optional, but if you leave it off, then > the other bind attributes are evaluated according to the inscope evaluation > context. This is handy when you are using inner binds. So, for example, > you can say > > <xf:bind nodeset="some/common/node"> > <xf:bind relevant="some expression"/> > <xf:bind nodeset="some child" calculate="some expression"/> > </xf:bind> > > Notice that the inner bind with the relevant attribute has no nodeset > attribute. > > If you have an outermost bind with no nodeset, then the model item property > is being attached to the default node, which is the root element of the > default instance. > > Also, if you define the same model item property more than once for a given > node, the processor is supposed to quit with an exception. When you didn't > use nodeset, you were attaching two relevant model item properties to the > root element of the default instance, which is why your program wasn't > working. If you had tried to do a second calculate, you would have gotten > the same error. > > As Mark explained, attributes like relevant and calculate are not applied to > the bind itself, which is what I believe you were thinking. Instead, the > bind *binds* those properties to data nodes. Then, your UI controls use > "single node bindings" (e.g. ref) to refer to the same nodes in order to get > at their value (whether or not calculated) and their other model item > properties (like relevant). > > Cheers, > John M. Boyer, Ph.D. > STSM, Interactive Documents and Web 2.0 Applications > Chair, W3C Forms Working Group > Workplace, Portal and Collaboration Software > IBM Victoria Software Lab > E-Mail: boyerj@ca.ibm.com > > Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer > Blog RSS feed: > http://www.ibm.com/developerworks/blogs/rss/JohnBoyer?flavor=rssdw > > > > > From: Mark Birbeck <mark.birbeck@webbackplane.com> > To: adam.flinton@nhs.net > Cc: "www-forms@w3.org" <www-forms@w3.org> > Date: 08/06/2009 05:50 AM > Subject: Re: Binding : Do I need a nodeset? > ________________________________ > > > Hi Adam, > > You always need a nodeset, even with @calculate. I'm surprised that > you are getting Chiba to output something using @calculate with no > @nodeset value, so you might want to double-check that you really are > seeing what you think you are seeing. > > One way to understand xf:bind is to see it as adding extra > 'properties' to an instance node. I realise that in your particular > example you want to have relevance based only on the result of an > expression, but that's not possible; in XForms you have to make some > existing node relevant, based on the expression you want. And if no > obvious node exists, then unfortunately, as you have discovered, you > usually need to invent one. > > So the minimum you will need is this: > > <xf:bind > nodeset="instance('systemInformation')//@localEdit[1]" > relevant=" > instance('OIDVals')//oids[1]/@active = 0 > and > instance('systemInformation')//@nodeEditable[1] = 1 > " > /> > > The reason I say "minimum" is that I haven't added an @id value here. > You only need the @id value if you want a shorthand for the node > referred to by @nodeset. If all you want is the relevance mechanism > itself, you can do this: > > <xf:group ref="instance('systemInformation')//@localEdit[1]"> > ... > </xf:group> > > I mention this only to draw attention to the two roles that xf:bind > plays -- one to give a 'name' to a nodeset, and the other to add extra > 'properties' to each node in that nodeset. > > Of course, in your example it's a good idea to use the named binding > feature too, so that you don't need to worry about keeping the two > XPath expressions in sync: > > <xf:bind > id="bnd-oid-edit" > nodeset="instance('systemInformation')//@localEdit[1]" > relevant=" > instance('OIDVals')//oids[1]/@active = 0 > and > instance('systemInformation')//@nodeEditable[1] = 1 > " > /> > > <xf:group bind="bnd-oid-edit"> > ... > </xf:group> > > If you're wondering about the "bnd-oid-edit" ID value, by the way, > it's because over the years we've discovered that a little Hungarian > notation can go a long way to helping keep the numerous @id values > that you need in XForms, distinct. > > It's also worth pointing out -- and I hope I'm not telling grandmother > to suck eggs here :) -- that "//" usually causes quite a performance > hit in XSLT/XPath engines, so it's often worth spelling out the full > XPath for your instance data. (Especially if you are mapping that > XPath to a named nodeset, via xf:bind.) > > Regards, > > Mark > > On Thu, Aug 6, 2009 at 1:58 PM, Adam Flinton<adam.flinton@nhs.net> wrote: >> Dear All, >> >> I have a couple of groups one for editing (i.e. uses input fields) & one >> for readonly (ie only uses output fields). >> >> Which to show is determined by binding to a bind which has a "relevant" >> attrib set e.g. >> >> <xforms:bind id="OID_EDIT" >> relevant="instance('OIDVals')//oids[1]/@active = 0 and >> instance('systemInformation')//@nodeEditable[1] = 1" >> nodeset="instance('systemInformation')//@localEdit[1]"/> >> <xforms:bind id="OID_NO_EDIT" >> relevant="instance('OIDVals')//oids[1]/@active = 1 and >> instance('systemInformation')//@nodeEditable[1] = 1" >> nodeset="instance('systemInformation')//@localNoEdit[1]"/> >> >> & then: >> >> <xforms:group appearance="minimal" bind="OID_EDIT" >> id="OID_Group_Editable"> >> >> etc. >> >> I can only seem to get it to work (in Chiba) is via having a nodeset >> which is just there to bind to. I.e. I create 2 dummy/empty attributes >> within an instance & use them as the nodeset reference. >> >> Do I need a nodeset ? >> >> e.g. should >> >> <xforms:bind id="OID_EDIT" >> relevant="instance('OIDVals')//oids[1]/@active = 0 and >> instance('systemInformation')//@nodeEditable[1] = 1" /> >> <xforms:bind id="OID_NO_EDIT" >> relevant="instance('OIDVals')//oids[1]/@active = 1 and >> instance('systemInformation')//@nodeEditable[1] = 1" /> >> >> Work in the same way? >> >> It appears to work for calculated values e.g. >> >> <xforms:bind id="CountOv" calculate="count(instance('OIDVals')//ov)"/> >> >> So are there any rules wrt binding & when you need a nodeset & when you >> don't? >> >> TIA >> >> Adam >> >> >> ******************************************************************************************************************** >> >> This message may contain confidential information. If you are not the >> intended recipient please inform the >> sender that you have received the message in error before deleting it. >> Please do not disclose, copy or distribute information in this e-mail or >> take any action in reliance on its contents: >> to do so is strictly prohibited and may be unlawful. >> >> Thank you for your co-operation. >> >> NHSmail is the secure email and directory service available for all NHS >> staff in England and Scotland >> NHSmail is approved for exchanging patient data and other sensitive >> information with NHSmail and GSI recipients >> NHSmail provides an email address for your career in the NHS and can be >> accessed anywhere >> For more information and to find out how you can switch, visit >> www.connectingforhealth.nhs.uk/nhsmail >> >> >> ******************************************************************************************************************** >> >> >> > > > > -- > Mark Birbeck, webBackplane > > mark.birbeck@webBackplane.com > > http://webBackplane.com/mark-birbeck > > webBackplane is a trading name of Backplane Ltd. (company number > 05972288, registered office: 2nd Floor, 69/85 Tabernacle Street, > London, EC2A 4RR) > > > > -- Mark Birbeck, webBackplane mark.birbeck@webBackplane.com http://webBackplane.com/mark-birbeck webBackplane is a trading name of Backplane Ltd. (company number 05972288, registered office: 2nd Floor, 69/85 Tabernacle Street, London, EC2A 4RR)
Received on Thursday, 6 August 2009 14:43:07 UTC