This document is also available in these non-normative formats: diff-marked HTML .
The English version of this specification is the only normative version. Non-normative translations may also be available.
Copyright © 2008 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
The binding attributes module provides a collection of attributes that can be used to associate an object such as an XML element with XML data nodes using XPath expressions.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This document is a Working Draft of the W3C. This document has been produced by the W3C Forms Working Group as part of the Forms Activity within the W3C Interaction Domain. The authors of this document are the W3C Forms Working Group participants.
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
Comments on this document are welcome. Please send discussion comments to www-forms@w3.org. Please send formal comment about this document to the public editor mailing list www-forms-editor@w3.org. (archive).
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. The Working Group maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
1 Introduction
2 Bindings
2.1 Single-Node Binding Attribute Group
2.2 Node-Set Binding Attribute Group
3 Evaluation Context
4 XPath Function Library
4.1 Node-set Functions
4.1.1 The context() Function
5 References, Dependencies, and Dynamic Dependencies
6 Glossary Of Terms
A References
A.1 Normative References
B Acknowledgements (Non-Normative)
C Production Notes (Non-Normative)
This document describes the Binding Attribute Module, which includes a collection of attribute groups, XPath functions, and behavioral semantics useful for binding objects, such as [XML 1.0] elements, to XML data nodes and evaluating other XPath expressions based on evaluations contexts set by those bindings.
This document uses the terms must, must not, required, shall, shall not, recommended, should, should not, may, and optional in accord with [RFC 2119].
This section describes an extensible method of associating an object, such as an XML element, with an XML data node. A binding expression is an [XPath 1.0] expression that locates the XML data node to associate with an object. Section 3 Evaluation Context specifies how the evaluation context of the binding expression is determined. A binding attribute of an object is an attribute that contains a binding expression.
A binding object is an object, such as an XML element, that may contain a binding attribute. A bound object is a binding object that does contain a binding attribute.
This section defines attribute groups for two classes of bindings, the single node binding and the node set binding.
This section defines the Single-Node Binding Attribute Group. This section defines one attribute for the single-node binding attribute group. Modules of the consuming profile may add other attributes or semantics to this attribute group.
A binding expression interpreted as [XPath 1.0] and evaluated with an evaluation context defined in Section 3 Evaluation Context. The result is interpreted as an XPath nodeset, and the first node rule is applied to obtain at most one directly referenced XML data node.
The single-node binding associates the directly referenced XML data node with the bound object. The duration of the binding is specified in the definition of the bound object. For example, the binding may be ephemeral, lasting only as long as a behavioral operation, or the binding may persist as long as the bound object exists.
This section defines the Node-Set Binding Attribute Group. This section defines one attribute for the node-set binding attribute group. Modules of the consuming profile may add other attributes or semantics to this attribute group.
A binding expression interpreted as [XPath 1.0] and evaluated with an evaluation context defined in Section 3 Evaluation Context. The result is interpreted as an XPath nodeset that directly references zero or more XML data nodes.
The node-set binding associates the directly referenced XML data nodes with the bound object. The duration of the binding is specified in the definition of the bound object. For example, the bound object may simply use the directly referenced nodes in a behavioral operation, or the bound object may generate a multiplicity of related objects and implicitly bind each related object with one of the XML data nodes located by the node-set binding.
An object, such as an XML element, may have attributes containing XPath expressions that must be evaluated. According to [XPath 1.0], every XPath expression requires an evaluation context consisting of a node, position, size, variable bindings, function library, and namespace context. This section describes an extensible method for determining an in-scope evaluation context for an object, which may be used as the evaluation context for XPath expressions associated with the object.
The method of defining the in-scope evaluation context is based on the use of binding attributes. The following terms are used to describe the effects of bindings among objects that are related by a logical tree structure. An outermost object is an object that is not a logical descendant of an object that expresses a binding. A inner object is an object that is a logical descendant of an object that expresses a binding. A outer object is a bound object that is a logical ancestor of an inner object.
The first component of the in-scope evaluation context is the in-scope evaluation context node. The initial in-scope evaluation context node of an outermost object is defined by the consuming profile. The initial in-scope evaluation context node of an inner object is defined by the nearest ancestor outer object. If the outer object expresses a single-node binding that directly references an XML data node, then the directly referenced XML data node is the initial in-scope evaluation context node of the inner object. If the outer object expresses a node-set binding, and if the outer object associates each XML data node located by the node-set binding expression with a related object containing a copy of the content of the outer object, then the XML data node associated with the related object is the initial in-scope evaluation context node of the inner object.
To allow greater control over the in-scope evaluation context node, any object may override the initial in-scope evaluation context node using
the context attribute, which is defined to be part of the Single-Node Binding Attribute Group and the
Node-Set Binding Attribute Group.
An optional attribute containing an XPath expression evaluated using the initial in-scope evaluation context. The result of the expression is interpreted as a nodeset, the first node rule is applied, and the result overrides the in-scope evaluation context node of the object that bears this attribute.
If an object has no in-scope evaluation context node, then behaviors related to XPath expressions associated with the object are suppressed.
An object may have no in-scope evaluation context node for many reasons, including the possibility that the consuming profile defines no default node
for an outermost object, because the context attribute resolves to an empty nodeset, or because the object is an inner object and an outer
object ancestor has no in-scope evaluation context node.
The in-scope evaluation context position and size are based on the nodeset used to obtain the in-scope evaluation context node. For the initial
in-scope evaluation context, this is the nodeset that contains the initial in-scope evaluation context node. If the context attribute is
specified and results in a node, then the position and size are both 1 because the first node rule is applied to the context. If the nearest
ancestor outer object of an inner object expresses a node-set binding, then the initial in-scope evaluation context position of the inner object is based on
the position in the nodeset of the XML data node associated with the related object ancestor of the inner object, and the initial in-scope evaluation
context size of the inner object is based on the size of the nodeset obtained by the node-set binding of the outer object.
This module defines no XPath variables for the in-scope evaluation context. The consuming profile may add variables to the initial in-scope evaluation context. Any such variables are also added to the in-scope evaluation context.
The function library available to the initial in-scope evaluation context and the in-scope evaluation context is defined in 4 XPath Function Library.
Any namespace declarations in scope for the attribute bearing the XPath expression are applied to the in-scope evaluation context of the expression.
This section has described how the in-scope evaluation context of an object is determined, not whether the in-scope evaluation context will be used
to evaluate an XPath expression associated with the object. The initial in-scope evaluation context is used to evaluate the context attribute
of an object, if one is specified. The in-scope evaluation context is used to evaluate a binding expression of an object, if one is specified.
By default, the in-scope evaluation context of an object is used to evaluate any other attributes of an object unless the attribute definition specifies
otherwise. For example, it is possible to evaluate an attribute of an object using an evaluation context that is based on the object's binding expression.
The function library for XPath expressions includes the entire [XPath 1.0] Core Function Library, including operations on node-sets, strings, numbers, and booleans. This section provides an addtional function that is required to implement by this module. Other modules of the consuming profile may add more functions to the function library.
node-set context()
This function returns the in-scope evaluation context node of the nearest ancestor object of the attribute containing the XPath expression that invokes this function. The nearest ancestor object may be related to an object that expresses a node-set binding as described in Section 3 Evaluation Context.
Example:
<setvalue ref="x" value="context()/y"/>
In this example, the element setvalue has a binding attribute ref whose result is used as the evaluation context node node of the value attribute.
The context() function returns the in-scope in-scope evaluation context node for the setvalue element.
An XPath expression references a node of XML data if the node is selected during the evaluation of the expression. A node is selected by matching an XPath NodeTest or by being returned by a function call. For examples, a node can match a name test, a wildcard test, a node type test, or it can be returned by or used as a parameter to a function, or it can appear in a filter expression (where all of the prior examples recursively apply). Once selected, a node is considered to be referenced even if a filter expression subsequently excludes the node from further participation in the expression evaluation. The reference list of an XPath expression is the set of XML nodes that it references.
Given the following XML data:
<data xmlns="">
<a attr="X">
<b attr="Y">
<c/>
</b>
<d/>
</a>
<a attr="Z">
<b>
<c/>
</b>
<d/>
</a>
</data>
and the following XPath expression:
a[@attr='X']/b[@attr='X']/c
Both nodes named a are referenced since both are matched by a NameTest. The attr attribute in each element a
is referenced during the evaluation of the filter expression. The filter expression rejects the second element a, but that element is still considered
to have been referenced because it was selected for further processing during the expression evaluation.
The element named b in the first element a is referenced, but element b in the second a is not referenced
because the expression evaluation did not proceed beyond the filter expression that rejected the second a element.
While performing the NameTest for element b, observe that an XPath expression evaluator may visit all the children of the first element a
in order to perform the NodeTest. However, a node is not referenced if it is only visited but fails the NodeTest. In this case, the NodeTest is a NameTest for b,
which the element d fails. Therefore, d is not referenced.
The filter expression test on b rejects the only element b that has been selected so far because the attribute value of attr
does not match the equality test. Still, b and its attribute attr have been referenced by this expression.
Element c is not considered to be referenced by this expression given this data. Although a NameTest for c appears in the expression,
the evaluation of the expression did not proceed to perform the NameTest due to the rejection of b by the filter expression.
Finally, note that an XPath expression can reference many nodes even if its final result is an empty nodeset.
Note:
Defining a reference in terms of matching a NodeTest was a deliberate design decision that creates more references than necessary in order to make various XPath-based systems more responsive to certain types of changes. When a leaf node is filtered from an expression by a predicate, the leaf node is still considered to be referenced so that if the condition changes such that the leaf node would be included in the result value of the expression, then it can be easily detected that the expression needs re-evaluation without evaluating other XPath expressions.
However, once a node is rejected from an expression, further location steps are not evaluated relative to the rejected node, so references for that location step are only created based on its execution relative to accepted nodes.
| Editorial note | |
| Part of the above note about the effect of rejected nodes on computational dependencies must be added to the calculate module. | |
| Editorial note | |
| Comments about referencing a repeat index with the index() function must be added to the repeat module. | |
If an XPath expression references an XML data node, then the expression result is dependent on the node. A dependency list for an XML data node is the list of XPath expressions of a given category that are dependent upon the node.
| Editorial note | |
| A comment about the relationship between dependency lists and order of recalculation must be added to the calculate module. | |
The references of an XPath expression may be altered by insertion of XML data nodes since the new nodes may be referenced by the XPath expression if it is re-evaluated. Similarly, the references of an XPath expression may be altered by deletion of XML data nodes that are being referenced by the XPath expression. An XPath expression is dynamically dependent on an XML data node if its reference list is altered by inserting, deleting or changing the value of the node. An XML data node is a dynamic dependency for an XPath expression if the expression is dynamically dependent on the node. If an XPath expression contains a dynamic dependency and dependency lists are being maintained for XPath expressions, then changing the dynamic dependency implies a change to the dependency lists of XML data nodes referenced by the XPath expression.
| Editorial note | |
| Comments about the relationship between dynamic dependencies, recalculate and rebuild must be added to at least one of the calculate module and the bind module. | |
[Definition: A "binding" connects an object, such as an XML element, to an XML data node using a binding expression as a locator. ]
[Definition: A binding attribute is an attribute whose value is a binding expression. ]
[Definition: A binding object is any object, such as an XML element, that may contain a binding expression attribute. ]
[Definition: An [XPath 1.0] expression used in a binding.]
[Definition: A bound object is a binding object that explicitly declares, or contains, a binding attribute. ]
[Definition: The consuming profile of a module is a collection of modules that includes and possibly extends the given module.]
[Definition: When an XPath expression selects a node-set of size > 1, the first node rule selects the first node in the node-set.]
[Definition: An object, such as an XML element, that is a logical descendant of an object that expresses a binding. An inner object need not express a binding since the object may have associated XPath expressions to be evaluated that are not binding expressions.]
[Definition: The in-scope evaluation context node of an object prior to
an override by the context attribute, if specified.]
[Definition: The in-scope evaluation context of an object prior to
an override by the context attribute, if specified.]
[Definition: The in-scope evaluation context for an object provides a default evaluation context for any XPath expressions associated with the object. This consists of an evaluation context node, a position for the evaluation context node, a size of a nodeset that contains the evaluation context node, a set of variable bindings, a function library, and a namespace context.]
[Definition: The in-scope evaluation context node provides a default evaluation context node for an object,
such as an XML element, that can be used to evaluate XPath expressions associated with the object, such as a binding expression in an attribute of the object.
The default in-scope evaluation context node of an outermost object is defined by the consuming profile. The default in-scope evaluation context for an inner object is determined
based on the binding expression of the nearest ancestor outer object. If an object expresses the context attribute, then the default in-scope evaluation context node
is used to evaluate the context expression, the first node rule is applied, and the result overrides the in-scope evaluation context node for the object. If an object does
not have an in-scope evaluation context node, then behaviors related to XPath expressions associated with the object are suppressed.]
[Definition: A node-set binding is a binding that is capable of associating any number of XML data nodes with the object that bears the node-set binding attribute. Modules of the consuming profile define the semantics of the association. For example, an object may simply use the multiplicity of nodes in a behavioral operation, or the object may generate a multiplicity of related objects and implicitly bind each related object with one of the XML data nodes located by the node-set binding.]
[Definition: An object, such as an XML element, that expresses a binding and is a logical ancestor of an inner object.]
[Definition: An object, such as an XML element, that is not a logical descendant of an object that expresses a binding. The set of outermost objects have an in-scope evaluation context that is defined by the consuming profile. Thus, an outermost object need not express a binding since the object may have associated XPath expressions to be evaluated that are not binding expressions.]
[Definition: For an object that expresses a node-set binding, a related object is an object that is created to represent a copy of the content of the object and associated with one XML data node from the node-set binding. Typically, one related object is created per XML data node located by an object's node-set binding.]
[Definition: A single-node binding is a binding that is capable of associating at most one XML data node with the object that bears the single-node binding attribute. The XML data node is selected by applying the first node rule to the result of the binding expression.]
This document was produced with the participation of Forms Working Group participants. Current participants include:
This document was encoded in the XMLspec DTD v2.6. The XML sources were transformed using diffspec and xmlspec stylesheets, version 2.6. The XML Schema portion of the Appendix was rendered into HTML with the xmlverbatim XSLT stylesheet (used with permission). The primary tool used for editing was XMLSpy. The XML was transformed using the XSLT processor in Java 6. The editor(s) use the W3C CVS repository and the W3C IRC server for collaborative authoring.