W3C home > Mailing lists > Public > www-forms@w3.org > February 2004

RE: A note on <bind /> (similar to <group />)

From: Mark Birbeck <mark.birbeck@x-port.net>
Date: Thu, 5 Feb 2004 15:30:48 -0000
To: "'David Landwehr'" <dlandwehr@novell.com>
Cc: <www-forms@w3c.org>, <Leigh.Klotz@pahv.xerox.com>
Message-ID: <002f01c3ebfd$07cbb5f0$6b01a8c0@W100>

David,

> That is interesting. Is there backup for this in the spec today ...

I'd say that although it's a good candidate for clarification, the spec
already allows it.

The spec actually doesn't say whether @nodeset is optional or required
on xf:bind [1]. However, the schema (which is normative) *does* say that
@nodeset is optional [2]. This therefore leads to a number of possible
arrangements, many of which I believe are very useful.

For example, you could break this:

    <bind nodeset="task" readonly="true()" relevant="true()" />

into this:

    <bind nodeset="task">
      <bind readonly="true()" />
      <bind relevant="true()" />
    </bind>

Why is that useful? Well for a start it makes it easier to document what
you are doing:

    <bind nodeset="task">
      <!--
        A task is not editable if complete
      -->
      <bind readonly="status='status#1'" />

      <!--
        If the task is to send an email, then we need to
        know who to
      -->
      <bind constraint=
        "boolean-from-string(
          if(
            type='email',
            if(who,'true','false'),
            'true')
        )"
      />
    </bind>


It also makes it easier to build 'packets' of business rules that can be
used in other places. For example, a company could have a company-wide
policy that if someone is applying for a loan larger than 5000, they
must provide a contact phone number:

    <bind constraint=
      "boolean-from-string(
        if(
          amount &gt; 5000,
          if(phoneNumber,'true','false'),
          'true')
      )"
    />

If this is then placed on a central server in the way Leigh described,
and XInclude is used to pick this up, one form might look like this:

    <bind nodeset="shortTermLoanApplication">
      <xi:include href="business-rules.xml" />
    </bind>

whilst another form might have this:

    <bind nodeset="studentLoanApplication">
      <xi:include href="business-rules.xml" />
    </bind>

The company's rules can now be changed in one place.

Leigh's use of <bind /> is a special case of this, where if you have a
number of rules in the central file, you would need to encapsulate them
all in a single xf:bind:

    <bind>
      <bind readonly="true()" />
      <bind constraint=". &gt; 7" />
    </bind>

The expansion (after include) would then be something like this:

    <bind nodeset="...">
      <!-- start inclusion of rules --->
      <bind>
        <bind readonly="true()" />
        <bind constraint=". &gt; 7" />
      </bind>
      <!-- end inclusion --->
    </bind>

> ... e.g. should an implementation do this today?

I believe they should. formsPlayer does.

Regards,

Mark

[1] <http://www.w3.org/TR/xforms/slice3.html#structure-bind-element>
[2] <http://www.w3.org/TR/xforms/sliceA.html>


Mark Birbeck
CEO and CTO
x-port.net Ltd.
Received on Thursday, 5 February 2004 10:31:06 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:21:57 GMT