Provides an overview of the namespace for calculation script.
This chapter provides an overview and usage of the namespace for the calculation script, and its elements and attributes.
Provides an overview of the namespace for calculation script.
This namespace provides the scheme to perform a calculation in the XML document processed in VC.
The namespace URI reference of calculation script is located at http://xmlns.xfytec.com/calc. In the descriptions below, we use the namespace prefix calc: for an element used in calculation script.
As for how to use a calculation script, there exists a method to apply a defined script, and the method to embed a calculation script into the attribute of any element (attribute embedding).
As for the method to use a calculation script by applying it to an XML document, there are the following two methods:
com.xfytec processing instruction with the calculation parameter in the XML document, as shown below:
<?com.xfytec calculation href="URL of calculation script file" ?>
id attribute in the calc:calc element for the embedded calculation script. Then, in the com.xfytec calculation processing instruction, you write the ID value that you specified in id attribute of the calculation script.
<?com.xfytec calculation href="#Value of IDattribute of calc:calc element for an embedded calculation script" ?>Describe the calculation script embedding into an XML document within the root element of the target XML document.
If multiple calculation scripts are applied in com.xfytec calculation processing instruction, the first described calculation script takes precedence.
When you describe a calculation script using attribute embedding, specify a calculation for the calc:expression global attribute, and then specify the attribute for the element into which calculation script is embedded.
The timing of performing a calculation differs depending on whether the content of the node to which the expression described in the calculation script refers is changed or whether the expression described in the calculation script itself is changed.
calc:expression global attribute is deleted or the element where the calc:expression global attribute is set is deleted, the calculation based on the calculation script is not executed.
If the reference between the calculation and the referred node becomes circular, the calculation will be done only once without iterating.
Explains the elements and attributes defined in the namespace for the calculation script.
Elements and attributes used to describe the calculation script are listed below.
calc:calc ElementIncludes the whole calculation script.
id
Identifies the calc:calc element. It can be an ID value. If a calculation script is embedded into an XML document, it identifies the calc:calc element by the ID value specified in this attribute.
If omitted, the attribute value is not assumed to be set.
version (mandatory)
Sets calculation script version number. This attribute is mandatory. This must be 1.0.
In calc:calc element, one or as many calc:bind elements as needed can be specified.
calc:bind ElementSpecifies the calculation and the node to output the calculation result. It can be a node set for the destination to output the calculation result. If a node set is specified, the calculation result is output to each element within the node set.
target (mandatory)
Specifies a node or a node set to output the calculation result. It can be an XPath expression. After an XPath expression's evaluation, the destination to output calculation result may vary according to the obtained node type.
The calculation is evaluated on the node specified in this attribute as a context node. If the node set is specified, the calculation is evaluated on each node in the node set as a context node.
expression (mandatory)
Sets an expression. It can be an XPath expression. The node referring to a number can be specified for the calculation. To specify the node, not only the absolute path, but also the relative path to the node specified in the target attribute or node set, is available.
The calc:bind element is empty.
The global attributes available when you describe a calculation script using attribute embedding are listed below.
calc:expression AttributeGlobal attribute used when you describe a calculation script within any element of XML document using attribute embedding. Specify XPath expression representing the calculation for the value.