Altova StyleVision 2024 Enterprise Edition

Editing and Moving Auto-Calculations

Home Prev Top Next

Creating Auto-Calculations

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).

 

Click to expand/collapse

 

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.
3.Optionally, if you wish to copy the value of the Auto-Calculation to a node in the XML document, you can select that node via an XPath expression. How to update nodes with the result of the Auto-Calculation is described in the section, Updating Nodes with Auto-Calculations.

 

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 Authentic View or an Output View.

 

Java and .NET functions

Java and .NET functions can be used in the XPath expressions of Auto-Calculations. Here are examples of XPath expressions containing Java and .NET functions:

 

Java:        java:java.util.Date.toString(java:java.util.Date.new() )

.NET:        clitype:System.Math.PI()

 

See the Appendices for more information about these extension functions.

 

Note:Java and .NET functions in Auto-Calculations are supported only in the Enterprise editions of Authentic Desktop and Authentic Browser.

 

Editing Auto-Calculations

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.

 

WinPropsAutoCalcEditXPath

 

Formatting Auto-Calculations

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 (except in the RTF output). An example of such an XPath expression is:

 

translate('a;b;c', ';', codepoints-to-string(13))

 

Moving Auto-Calculations

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.

In Authentic View, an Auto-Calculation is re-evaluated each time any value relevant to the calculation (that is, any node included in the XPath expression) changes.

An Auto-Calculation result is non-editable in Authentic View or any other output view.

Any node in the XML document can be updated with the result of the Auto-Calculation.

 

© 2017-2023 Altova GmbH