Passing parameters in transforms

The pipeline:parameter element specifies the name and value of each parameter. The value may be passed as a DCI expression using the value attribute or as body content if it is a text element or complex infoset.

The pipeline:parameter element specifies the name and value of each parameter. The value may be passed as a DCI expression using the value attribute or as body content if it is a text element or complex infoset.

You can define a single pipeline:parameters element as the first child of a pipeline:transform. It can contain one or more pipeline:parameter elements. All the XSL transforms that you refer to in the related pipeline:transformation elements must declare a xsl:param element with a name matching each of the pipeline parameters.

Simple parameters

The example demonstrates a transform element with a parameter block declared:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:pipeline="http://www.volantis.com/xmlns/marlin-pipeline"
  xmlns:webd="http://www.volantis.com/xmlns/marlin-web-driver">
  <head>
    <title>pipeline:parameters</title>
  </head>
  <body>
    <div>
      <pipeline:transform>
        <pipeline:parameters>
          <pipeline:parameter name="header_param" value="Welcome to Seattle"/>
        </pipeline:parameters>
        <pipeline:transformation href="test.xsl"/>
        <webd:get url="http://weather.yahooapis.com/forecastrss">
          <webd:parameters>
            <webd:parameter name="p" value="USWA0395"/>
            <webd:parameter name="u" value="c"/>
          </webd:parameters>
        </webd:get>
      </pipeline:transform>
    </div>
  </body>
</html>

The transform references the stylesheet test.xsl. It defines the global xsl:param name 'header_param' that is later referenced in the template like any other XSL parameter or variable, and output as a header.

The names of the pipeline parameters match an equivalent xsl:param element in the stylesheet that follows. If the transform element contained multiple transformation elements the parameters would be passed to the stylesheet for each transformation.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0"
  xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
  <xsl:output method="xml"/>
  <xsl:param name="header_param"/>
  <xsl:template match="/">
    <div xmlns="http://www.w3.org/2002/06/xhtml2">
      <h3>
        <xsl:value-of select="$header_param"/>
      </h3>
      <p>Current Conditions: <xsl:value-of select="/rss/channel/item/yweather:condition/@text"/>,
        <xsl:value-of select="/rss/channel/item/yweather:condition/@temp"/>
        <xsl:value-of select="/rss/channel/yweather:units/@temperature"/>.</p>
    </div>
  </xsl:template>
</xsl:stylesheet>

Related topics