FW: Evaluating the relevant property expression when the bound instance node doesn't exist...

Erik,

Thank you for the swift reply.


> I think there is a mistake in your code above

Opps, how red-faced am I?

I don't have a problem with any of the points you make except one:

> Now there is a twist: a control bound to a non-existing node is 
> considered non-relevant.

If a control is non-relevant because it is bound to a non-existent node,
surely that would imply that the control should be rendered
in-accessible and therefore it would be impossible, for example, to add
attributes to a node that had not had those attributes already declared!

That doesn't seem to make any sense.


In essence, I want to create a dependency between two attributes such
that it doesn't make sense to have the later without the former.
However, if both attributes are implied then how can you test the
dependency, as expressed with the relevance MIP, if:

a) The context for the test is the later and,
b) the later doesn't exist.


I've reworked my example with some of your corrections:

<xforms:model>

	<xforms:instance xmlns="">
		<area x="0" y="0"/>
	</xforms:instance>

	<xforms:bind id="area.width" nodeset="@width"
relevant="../@height"/>

</xforms:model>


<xforms:input bind="area.width">
	...
</xforms:input>

1)	I must be able to input a value for @width regardless of whether
it 
	has already been specified in the instance data.

2) 	If I want to have the ability to prevent the input a values for
@width 
	if @height has not already been defined then the relevance
expression is 
	meaningless without a valid context (in this case @width).

If, as I believe this problem cannot be solved as it is expressed then
can I express the binding and the relevance test in another way so that
the absence of a valid context node is not an issue?

For example:

<xforms:model>

	<xforms:instance xmlns="">
		<data>
			<area x="0" y="0"/>
		</data>
	</xforms:instance>

	<xforms:bind id="area.width" nodeset="area" calculate="@width"
relevant="@height"/>

</xforms:model>


<xforms:input bind="area.width">
	...
</xforms:input>



Regards

Philip Fennell



-----Original Message-----
From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On
Behalf Of Erik Bruchez
Sent: 12 February 2007 14:38
To: www-forms@w3.org
Subject: Re: Evaluating the relevant property expression when the bound
instance node doesn't exist...


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 17:10:20 UTC