BASICS

ADMINISTRATION

DEVELOPMENT

SUPER ADMIN

  LAST UPDATED
11/20/2012

XSL Parameters

Publish Control Files (PCF) are now able to specify arbitrary parameters to be passed to the referenced XSL stylesheets. Parameters are defined in each processing instruction of the PCF, allowing a single XSL stylesheet to service multiple targets.

Defining the Parameters

Parameters are passed to the XSLT engine as an attribute of the pcf-stylesheet instruction. Multiple parameters can be passed at once, and are referenced in name=value pairs separated by semicolons.

<?pcf-stylesheet path="/xsl/index.xsl" params="image=test.jpg;caption=test image" extension="html"?>

In the above example, two parameters are being passed to the XSL stylesheet: image, with the value test.jpg, and caption, with the value test image.

Since parameters are defined in each pcf-stylesheet instruction, the PCF can pass different parameters (or the same parameters with different values) for each processing instruction.

<?pcf-stylesheet path="/xsl/index.xsl" params="image=test.jpg;caption=test image" extension="html"?>
<?pcf-stylesheet path="/xsl/index.xsl" params="pagestyle=mobile;image=test-mobile.jpg;caption=test image" extension="html" alternate="yes"?>
<?pcf-stylesheet path="/xsl/index.xsl" params="columns=15" extension="csv" alternate="yes"?>

 

Next Page

 

Accessing the Parameters in an XSL Stylesheet

Parameters that are being passed in to an XSL file must be declared in the XSL stylesheet before they can be accessed. In order to declare parameters globally in the XSL file, an xsl:param element must be defined and named for each parameter, just inside of the opening xsl:stylesheet element.

<xsl:param name="image"/>
<xsl:param name="caption"/>

Once they are defined, parameters can then be referenced inside of the XSL stylesheet using an xsl:value-of element.

<xsl:value-of select="$image"/>
<xsl:value-of select="$caption"/>

 

Previous Page

 


Was this page helpful?

Additional Comments:


(Include your email address if you would like a reply)

Procede to http://support.omniupdate.com/