SET XSLT PARAMETER

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

version 2004


SET XSLT PARAMETER (paramName; paramValue)

ParameterTypeDescription
paramNameStringName of the parameter to look for in the XSL sheet
paramValueStringValue of the parameter to use in the transformed
document

Description

The SET XSLT PARAMETER command must be used jointly with the APPLY XSLT 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 APPLY XSLT TRANSFORMATION.

Notes:

For more information about XSL transformation (or XSLT), refer to the Overview of XML Utilities Commands section.

The scope of this command is the current process. It must be called in the same process as the associated APPLY XSLT TRANSFORMATION command.

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 SET XSLT PARAMETER command several times. The parameters are "stacked" until the APPLY XSLT TRANSFORMATION call in the same process. Once APPLY XSLT 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:

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

See Also

APPLY XSLT TRANSFORMATION, GET XSLT ERROR.

System Variables or Sets

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


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next