![]() |
| Previous Top Next |
Auto-Calculations |
The Auto-Calculation feature (i) displays the result of an XPath evaluation at any desired location in the output document, and (ii) optionally updates a node in the XML document with the result of the XPath evaluation.
The Auto-Calculation feature is a useful mechanism for including:
| • | Calculations involving operations on dynamic data values. For example, you can count the number of Employee elements in an Office element (with count(Employee)), or sum the values of all Price elements in each Invoice element (with sum(Price)), or join the FirstName and LastName elements of a Person element (with concat(FirstName, ' ', LastName)). In this way you can generate new data from dynamically changing data in the XML document, and send the generated data to the output. |
| • | Calculations based on the dynamic structure of the document. For example, you can use the position() function of XPath to dynamically insert row numbers in a dynamic table, or to dynamically number the sections of a document. This has the advantage of automatically generating information based on dynamically changing document structures. |
| • | Inserting data from external XML documents. The doc() function of XPath 2.0 provides access to the document root of external XML documents, and thus enables node content from the external XML document to be inserted in the output. |
| • | The value of nodes in the XML document can be changed by updating them with the value of an Auto-Calculation. For example, the node Addressee could be updated with an XPath expression like concat(Title, ' ', FirstName, ' ', LastName). |
| • | The Auto-Calculation feature is also a useful way to display the contents of some node at another location. |
See also:
Reference: Auto-Calculation, for a description of how to access and use the Auto-Calculation dialog.
XPath Dialog, for a description of the Edit XPath Expression dialog.
XSLT Engine Information, for information about XPath support.
|