To create an Auto-Calculation, do the following:
|1.||Place the cursor as an insertion point at the location where the Auto-Calculation result is to be displayed and click Insert | Auto-Calculation. In the submenu that appears, select Value if the result is to appear as plain text, select Input Field if it is to appear within an input field (i.e. a text box), or select Multiline Input Field if it is to appear in a multiline text box. (Note that the output of the Auto-Calculation is displayed as a value, or in an Input Field. It is an output in Authentic View, and cannot be edited there.) The Edit XPath Expression dialog pops up (screenshot below).|
|2.||In the Expression pane, enter the XPath expression for the Auto-Calculation via the keyboard. Alternatively, enter the expression by double-clicking nodes, operators, and/or functions in the respective panes of the dialog. It is important to be aware of the context node at the insertion point; the context node is highlighted in the schema source tree (in the screenshot above the context node, newsitems, is highlighted). If you have selected XSLT 1.0 as the version of the XSLT language for your SPS, then you must use XPath 1.0 expressions; if you have selected XSLT 2.0 or XSLT 3.0, then you must use, respectively, XPath 2.0 or XPath 3.0 expressions. For a detailed description of the Edit XPath Expression dialog, see the section Edit XPath Expression.|
Click the OK button finish. In the Design tab, the Auto-Calculation symbol is displayed. To see the result of the Auto-Calculation, change to HTML View.
To edit the XPath expression of the Auto-Calculation, select the Auto-Calculation and, in the Properties sidebar, click the Edit button of the XPath property in the AutoCalc group of properties (screenshot below). This pops up the Edit XPath Expression dialog (screenshot above), in which you can edit the XPath expression.
You can apply predefined formats and CSS styles to Auto-Calculations just as you would to normal text: select the Auto-Calculation and apply the formatting. Additionally, input formatting of an Auto-Calculation that is a numeric or date datatype can be specified via the Input Formatting property in the AutoCalc group of properties in the Properties window.
Note also that you can include carriage returns and/or linefeeds (CR/LFs) in the XPath expression. If the Auto-Calculation is enclosed in the pre special paragraph type, the output of a CR/LF will produce a new line in the output. An example of such an XPath expression is:
translate('a;b;c', ';', codepoints-to-string(13))
You can move an Auto-Calculation to another location by clicking the Auto-Calculation (to select it) and dragging it to the new location. You can also use cut/copy-and-paste to move/copy an Auto-Calculation. Note, however, that the XPath expression will need to be changed if the context node in the new location is not the same as that in the previous location.
Summary of important points
Note the following points:
•An Auto-Calculation can be inserted anywhere in the Design Document.
•The point at which you insert the Auto-Calculation determines the context node for the XPath evaluation.