Altova StyleVision 2024 Professional Edition

Updating Nodes with Auto-Calculations

Home Prev Top Next

You can copy the value (or result) of an Auto-Calculation to a node in the main XML document (the document being edited in Authentic View). You do this as follows:

 

1.Create the Auto-Calculation as described in Editing and Moving Auto-Calculations.

2.Select the Auto-Calculation and, in the Properties sidebar, click the Edit button of the Update XML node in Authentic property in the Authentic group of properties (screenshot below).

 

WinPropsAutoCalcUpdateNode

 

3.In the XPath Selector dialog that pops up (screenshot below), select the node to update and click OK to finish. If you wish the XPath expression to be absolute (that is, starting at the document root), check the Absolute XPath check box.

 

DlgSchemaSelector

 

Alternatively, if you select the User-Defined XPath radio button, you can enter any XPath expression you like to select the node to be updated.

 

The XPath expression must select a single node. If the XPath expression selects multiple nodes, no node will be updated.

 

IMPORTANT!

For a node in the main XML document to be updated two conditions must be fulfilled:

 

1.The XPath expression for the Auto-Calculation must include at least one value that is related to an XML node, i.e. a dynamic value. For example, Price*1.2. This expression involves the element Price, and is therefore dynamic. If the XPath expression contains a static value (for example, string("Nanonull, Inc.")), then the Update XML Node feature will not work.

2.Any one of the nodes used in the XPath expression must be modified in Authentic View. So, if the XPath expression is Price*1.2, and the Auto-Calculation is set to update the VATPrice node, then the Price element must be modified in Authentic View in order for the VATPrice node to be updated.

 

Changing the node to update, cancelling the update

To change the node to update, click the Edit button of the Update XML Node property in the Authentic group of properties of the Auto-Calculation (in the Properties window) and then select the required node from the Schema Selector dialog box that pops up. To delete the Update XML Node property, click the Remove button in the toolbar of the Properties window.

 

Should you use the Auto-Calculation or the updated node contents for display?

If there are no conditional templates involved, you can use either the Auto-Calculation or the contents of the updated node for display. It is immaterial which one you choose because the node update happens immediately after the Auto-Calculation is evaluated and there is no factor to complicate the update. You should, however, be aware that there is a different source for the content displayed in each of the two cases.

 

Hiding the Auto-Calculation

You may find yourself in the situation where you wish to use an Auto-Calculation to make a calculation in order to update a node with the value of the Auto-Calculation. In this case, one of the following scenarios arises:

 

You wish to display the result just once. You cannot hide the Auto-Calculation since it would then not be evaluated. If there is no conditional template involved, it is best to display the Auto-Calculation and not display the contents of the updated node.

You wish not to display the result, merely to update the node. The best way to handle this scenario is to apply text formatting to the Auto-Calculation, so that it is invisible on the output medium (for example, by applying a white color to an Auto-Calculation on a white background).

 

© 2017-2023 Altova GmbH