User-Declared Parameters

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  SPS File: Advanced Features > Parameters and Variables >

User-Declared Parameters

In an SPS, user-declared parameters are declared globally with a name and a default string value. Once declared, they can be used in XPath expressions anywhere in the SPS. The default value of the parameter can be overridden for individual XSLT transformations by passing the XSLT stylesheet a new global value via StyleVision Server.

 

Use of parameters

User-declared parameters are useful in the following situations:

 

If you wish to use one value in multiple locations or as an input for several calculations. In this case, you can save the required value as a parameter value and use the parameter in the required locations and calculations.
If you wish to pass a value to the stylesheet at processing time. In the SPS (and stylesheet), you use a parameter with a default value. At processing time, you pass the desired value to the parameter via StyleVision Server.

 

Usage mechanism

Working with user-declared parameters in the SPS consists of two steps:

 

1.Declaring the required parameters.
2.Referencing the declared parameters.

 

Declaring parameters

All user-defined parameters are declared and edited in the Edit Parameters dialog (screenshot below). The Edit Parameters dialog is accessed via: the Edit | Stylesheet Parameters command.

 

dlg_edit_params1

 

Declaring a parameter involves giving it a name and a string value—its default value. If no value is specified, the default value is an empty string.

 

To declare a parameter, do the following:

 

1.In the Edit Parameters dialog, append or insert a new parameter by clicking the Append or Insert buttons. A new line appears.
2.Enter the name of the parameter. Parameter names must begin with a letter, and can contain the characters A to Z, a to z, 0 to 9, and the underscore.
3.Enter a default value for that parameter. The value you enter is accepted as a text string.

 

You can insert any number of parameters and modify existing parameters at any time while editing the SPS.

 

Note:

 

The Edit Parameters dialog contains all the user-defined parameters in an SPS.
Parameters can also be declared in the Design Overview sidebar.

 

Referencing declared parameters

Parameters can be referenced in XPath expressions by prefixing a $ character before the parameter name. For example, you could reference a parameter in the XPath expression of an Auto-Calculation (e.g. concat('www.', $company, '.com')).

 

Note:While it is an error to reference an undeclared parameter, it is not an error to declare a parameter and not reference it.

 


© 2019 Altova GmbH