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)

Received on Thursday, 6 August 2009 12:47:35 UTC