- From: Erik Bruchez <ebruchez@orbeon.com>
- Date: Mon, 12 Feb 2007 15:38:21 +0100
- To: www-forms@w3.org
Fennell, Philip wrote:
> Hello,
>
> I believe I'm correct when I say that a relevant expression is
> evaluated relative to the target nodeset of a bind instruction. If
> so then, where an xforms:bind targets an attribute node e.g.
>
>
> <xforms:instance xmlns="">
> <area x="0" y="0"/>
> </xforms:instance>
>
> <xforms:bind id="area.width" nodeset="area/@width"
> relevant="../@height"/>
I'll start with something slightly off-topic: I think there is a
mistake in your code above: the default XPath evaluation context for
xforms:bind/@nodeset is the root element of the first instance of the
model, so you would have to write:
<xforms:bind id="area.width" nodeset="@width" relevant="../@height"/>
Alternatively, you can write:
<xforms:bind id="area.width"
nodeset="/area/@width"
relevant="../@height"/>
A practice I like, especially when there are many instances, is to
make things explicit and use the instance() function and provide an id
on your instance:
<xforms:instance xmlns="" id="my-instance>
<area x="0" y="0"/>
</xforms:instance>
<xforms:bind nodeset="instance('my-instance')">
<xforms:bind id="area.width"
nodeset="@width"
relevant="../@height"/>
</xforms:bind
or:
<xforms:bind id="area.width"
nodeset="instance('my-instance')/@width"
relevant="../@height"/>
> and the binding is only relevant if some other attribute exists, then if
> @width was absent, how could I test the relevancy of the 'area.width'
> binding?
1. Your question seems to imply that model item properties (MIPs) are
somehow stored and associated with the id of the xforms:bind.
But this is not the case: MIPs are stored on particular instance
data nodes. If the node referred to by the @nodeset attribute
doesn't exist, the MIP simply doesn't exist at all!
So you can't test a relevant, readonly, constraint, or type MIP if
there is no node pointed to by the xforms:bind/@nodeset attribute.
2. Following #1 above, and except for proprietary extension functions,
the only way to test the relevance of a node is to actually bind a
control to it!
Using the id "area.width" is just a shortcut to refer to the node
at area/@width. If you had a control bound this way:
<xforms:input bind="area.width">
This is equivalent to writing:
<xforms:input ref="/area/@width">
Once the control is bound to a node, it determines its relevance by
looking at whether the node is relevant or not (with inheritance).
Now there is a twist: a control bound to a non-existing node is
considered non-relevant. But this is specific to relevance, and
doesn't apply to the other MIPs.
> Would this example binding always be 'non-relevant' when the @width
> is missing?
As discussed in #2 above, a *control* defined as follows:
<xforms:input bind="area.width">
will be non-relevant because it is not bound to an existing node.
> If so does this imply that the form/data design is incorrect and the
> problem has to be resolved by a change to the schema and form?
Hard to tell without knowing what problem you are trying to solve ;-)
-Erik
--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/
Received on Monday, 12 February 2007 14:38:31 UTC