- From: John Boyer <boyerj@ca.ibm.com>
- Date: Mon, 8 Jan 2007 10:18:41 -0800
- To: Sébastien CRAMATTE <contact@zeninteractif.com>
- Cc: www-forms@w3.org, www-forms-request@w3.org
- Message-ID: <OFD9A8E4FC.18027A26-ON8825725D.00635930-8825725D.00649975@ca.ibm.com>
Hi Sebastien,
The problem you are having is because you are not capturing all of the
'referents' of the XPath expression.
The referents you need to capture are a superset of the final node
referenced in a binding or value.
To be concrete, in the expression sum(//class[@enable='true']/rate) that
you provided, it is true that the location path within the sum function
produces as output a number of 'rate' elements. However, the node set
that is 'referenced' during the entire evaluation of the expression
includes *all* of the enable attribute nodes on every class element that
is matched. The typical implementation would even include all of the
class elements themselves because they were 'matched' during the
evaluation.
The key is that the node must be matched, not just visited, in order to be
included in the reference list for the expression. For example, suppose
your instance below also included some 'noclass' elements interspersed as
siblings of the class elements. The location step //class would also
visit the noclass elements, but it would decide that they do *not* match.
This should correspond to not putting the noclass elements in the
reference list for the expression.
Also, as you explore your XPath engine, you are likely to notice that
matches come from a variety of sources, some of which constitute 'better'
matches and others are lower quality matches, e.g. a wildcard match. But
a match is a match when it comes to compiling the reference list for the
expression. The other thing to look out for is that you can also refer to
a node if it is returned by a nodeset returning function such as id() or
current().
Best regards,
John M. Boyer, Ph.D.
STSM: Workplace Forms Architect and Researcher
Co-Chair, W3C Forms Working Group
Workplace, Portal and Collaboration Software
IBM Victoria Software Lab
E-Mail: boyerj@ca.ibm.com http://www.ibm.com/software/
Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer
Sébastien CRAMATTE <contact@zeninteractif.com>
Sent by: www-forms-request@w3.org
01/06/2007 07:59 AM
To
www-forms@w3.org
cc
Subject
Question about dependency model and referents node in XPath Expression
Hello,
I've got a question about dependency model and referents node in XPath
Expression ...
Considering this XForms ...
<html>
<head>
<xf:model>
<xf:instance>
<root xmlns="">
<class enable="true">
<rate>10</rate>
</class>
<class enable="false">
<rate>15</rate>
</class>
<class enable="true">
<rate>20</rate>
</class>
</root>
</xf:instance>
<xf:bind nodeset="//class/@enable" type="xsd:boolean" />
</xf:model>
</head>
<body>
<xf:output value="sum(//class[@enable='true']/rate)" />
<xf:repeat nodeset="class">
<fieldset>
<legend>class</legend>
<xf:input ref="@enable">
<xf:label>Enable</xf:label>
</xf:input>
<xf:input ref="rate">
<xf:label>Rate</xf:label>
</xf:input>
</fieldset>
</xf:repeat>
</body>
</html>
As you can see using the repeat module I can display three class rate
value with a checkbox (type xsd:boolean) button to enable/disable each.
Considering this XPath output element :
<xf:output value="sum(//class[@enable='true']/rate)" />
When My XForms processor evaluate the expression and find "referents"
nodes bellow, only "rate" node with predicate @enable='true' are added
to dependency model during initial
"rebuild+recalculate+revalidate+refresh" sequence
Now, if I change @enable attribute value of the 2nd class node to 'true'
(intialiy @enable='false') and If i change the "rate" value the "sum"
output will not be recomputed.
I must check / uncheck the enable button to refresh it ...
My question is : does my XPath engine should ignore [@enable='true]
predicate and append all "rate" childs nodes as referents ?
When I force this behavior in my XPath lib the "sum" is recomputed
correctly when I change any rate value.
Thanks for you help
Regards
Received on Monday, 8 January 2007 18:19:08 UTC