A datapointer is an object that represents a pointer to a node in a
LzDataset
. The datapointer can be repositioned
using either cursor movements calls such as
selectNext(), or by running an XPath
request via setXPath().
Datapointers support a subset of the XPath specification, which uses a notation similar to the UNIX file-system to refer to nodes within a dataset. Once a datapointer is bound to a node in a dataset it will keep pointing to that node until it is moved. If the dataset is edited, the behavior of the datapointer will be controlled by its rerunxpath attribute. If this attribute is true, it will continue pointing to its current node as long as it is valid.
The example below demonstrates the use of some of the features of datapaths to retrieve data from a dataset.
Example 7. Using a datapointer to retrieve data from a dataset
<canvas height="80"> <simplelayout spacing="5"/> <dataset name="mydata"> <record> This is some text <deeper> <deeprecord> This is a deeper level </deeprecord> <deeprecord> It's dark down here! </deeprecord> <deeprecord> Last deep record </deeprecord> </deeper> </record> <record> This is more text </record> <record> Exciting no? </record> <record> The final line of text </record> </dataset> <view> <simplelayout/> <button> Move forward with select <handler name="onclick"> if (mydp.selectNext()) var s = else var s = "hit last record; reset with xpath"; output.setText(s); </handler> </button> <button> Set with XPath <handler name="onclick"> if (mydp.getNodeName() == "record") var xp = else var xp = output.setText(); </handler> </button> </view> <text name="output" width="200">Data will appear here.</text> </canvas>
Properties (14)
rerunxpath
is true, the datapointer will
always rerun its remembered XPath (set with the
xpath
property). If it is false, the
datapointer will only verify that the node it is pointing to is
still in the dataset. If it isn't, the datapointer will rerun
its remembered xpath (if it has one) or will print a debug
message if any further attempt is made to use its current node
as the basis for a relative XPath query.
Setters (5)
Setters for virtual properties, to be used with setAttribute. A setter may or may not have a corresponding getter method; consult the Methods list in this section.
Methods (63)
Events (6)
xpath
changes. For XPaths which select a datanode, this means that the
datapointer is pointing to a new node. For XPaths which select text data,
this means that the datapointer is pointing to a new node, or that the
text selected by the xpath
has changed. Note that a datapointer mapped to
a data node will not receive ondata
when the node, say, changes one of
its attributes.
Copyright © 2002-2007 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.