eXforms - extending XForms 1.0

14 December 2006

This version:
http://exforms.org/variable.html
Editor:
David Landwehr, exforms.org

Status of this Document

This module defines an element which enables the use of variables in XPath expressions ([XPath 1.0]).

Table of Contents

1 Variable
    1.1 The Module
    1.2 The exf:variable Element
2 References
    2.1 Normative References

Appendix

A Acknowledgments (Non-Normative)


1 Variable

1.1 The Module

This module defines an element which enables the use of variables in XPath expressions ([XPath 1.0]).

The module name to be used for this extension is defined as exf:variable

1.2 The exf:variable Element

The exf:variable element introduces a variable to be used in XPath expression in the subtree of the parent to the exf:variable element.

Attributes

name

Required The name of the variable. This is a xsd:QName.

select

Required [XPath 1.0] expression which is the value assigned to the variable. The expression is evaluated in the context defined by [XForms 1.0] and by the model attribute on this element.

model

Optional The xforms model used for scoping which model the attribute correspons to.

For exf:variables in the model they are updated before the processing of the xforms-recalculate event and for exf:variable elements in the UI they are updated before the xforms-refresh event. A variable scope is defined in a model and from the parent of the exf:variable element and the last one with the same name takes precedens. It must be possible to defined identical named variables for different model in the same document scope.

Example: how to use exf:variable in the UI
<xforms:model>
  <xforms:instance>
    <data xmlns="">
      <a><b><c>value</c></b></a>
    </data>
  </xforms:instance>
</xforms:model>

<xforms:group>
  <exf:variable name="bvalue" select="a/b"/>
  
  The c value: <xforms:output ref="$bvalue/c"/>
</xforms:group>

Evaluates the binding to be the c node.

Example: how to use exf:variable in the model
<xforms:model>
  <xforms:instance>
    <data xmlns="">
      <a><b><c>value</c></b></a>
    </data>
  </xforms:instance>

  <exf:variable name="bnode" select="a/b"/>
  <exf:variable name="boolean" select="$bnode/c = 'value"/>

  <xforms:bind nodeset="$b" relevant="$boolean"/>
</xforms:model>

Uses a variable in a exf:variable element and in the relevant

2 References

2.1 Normative References

XForms 1.0
XForms - Version 1.0, John M. Boyer, David Landwehr, Roland Merrick, T. V. Raman, Micah Dubinko, Leigh L. Klotz, Jr., 2006. W3C Recommendation available at: http://www.w3.org/TR/xforms/.
XML Events
XML Events - An events syntax for XML, Steven Pemberton, T. V. Raman, Shane P. McCarron, 2002. W3C Recommendation available at: http://www.w3.org/TR/xml-events/.
XPath 1.0
XML Path Language (XPath) Version 1.0, James Clark, Steve DeRose, 1999. W3C Recommendation available at: http://www.w3.org/TR/xpath.
XML Schema part 1
XML Schema Part 1: Structures, Henry S. Thompson, David Beech, Murray Maloney, Noah Mendelsohn, 2001. W3C Recommendation available at: http://www.w3.org/TR/xmlschema-1/.
XML Schema part 2
XML Schema Part 2: Datatypes, Paul V. Biron, Ashok Malhotra, 2001. W3C Recommendation available at: http://www.w3.org/TR/xmlschema-2/.
RFC 2119
RFC 2119: Key words for use in RFCs to Indicate Requirement Levels, S. Bradner, 1997. Available at http://www.ietf.org/rfc/rfc2119.txt.

A Acknowledgments (Non-Normative)

eXforms.org would like to thank the following for their contributions in creating the extensions:

  • David Landwehr, exforms.org / SolidApp
  • Kenneth Sklander, picoforms.com
  • Allan Beaufour, beaufour.dk