4D v13.4

XSLT SET PARAMETER

Home

 
4D v13.4
XML
XSLT SET PARAMETER

XSLT SET PARAMETER 


 

XSLT SET PARAMETER ( paramName ; paramValue ) 
Parameter Type   Description
paramName  String in Name of the parameter to look for in the XSL sheet
paramValue  String in Value of the parameter to use in the transformed document

The XSLT SET PARAMETER command must be used jointly with the XSLT APPLY TRANSFORMATION command. It allows you to define values of variable parameters placed in an XSL style sheet when the XSLT transformation of an XML document begins. Using this command, it is possible to insert values coming from 4D processes in the XSL style sheets right before using XSLT APPLY TRANSFORMATION.

Notes:

Pass the name of the XSL variable parameter to replace in paramName. This parameter must be present in the XSL style sheet as $toreplace. However, the $ character is not necessary in paramName. For example, if the instruction <xsl:template match=$myvar> is placed in the XSL file, simply pass “myvar” in paramName to set this parameter.

In paramValue, pass the value that you wish to insert instead of the XSL variable in the transformed file. To use the above example, if you pass “title” in paramValue, the XSLT traansformation will take into account the <xsl:template match="title"> instruction (which set “title” elements as subject to style rules).

If the value type is string, you must include it between single quotes (for example 'myvalue') — in addition to the double quotes of the 4D syntax ("'myvalue'").

Note: For a detailed description of XSL language, you can refer to a number of sites on the Internet dedicated to this language. For example, http://xml.org.

To pass several parameters in an XSL style sheet, simply call the XSLT SET PARAMETER command several times. The parameters are “stacked” until the XSLT APPLY TRANSFORMATION call in the same process. Once XSLT APPLY TRANSFORMATION is executed, the “stack” of parameters is automatically deleted.

Example  

The following example defines two XSL parameters then transforms the document mydoc.xml into an HTML file using the style sheet mysheet.xsl:

 XSLT SET PARAMETER("varstyle";"'bold'")
 XSLT SET PARAMETER("varcolor";"'blue'")
 $xmldoc:="mydoc.xml"
 $xslsheet:="mysheet.xsl"
 $htmldoc:="mydoc.html"
 XSLT APPLY TRANSFORMATION($xmldoc;$xslsheet;$htmldoc)

If the command has been executed correctly, the system variable OK is set to 1. Otherwise, it is set to 0.

 
PROPERTIES 

Product: 4D
Theme: XML
Number: 883

The OK variable is changed by the command

 
INDEX

Alphabetical list of commands

 
HISTORY 

Created: 4D 2004
Renamed: 4D v12

 
SEE ALSO 

XSLT APPLY TRANSFORMATION
XSLT GET ERROR