Re: using p:variable


On 14 Dec 2008, at 10:20, Dave Pawson wrote:
> I've declared a variable, first child of a pipeline
> How can I obtain the value of that for direct inclusion
> within the pipeline result port please?

Variables hold strings. The result of a pipeline is an XML document.  
So you can't output the variable directly, but you can use it to  
create the value of an element or attribute by passing it in as the  
value of an option or parameter.

For example, if you wanted to pass its value into an XSLT step as a  
parameter to the XSLT, you could do:

<p:pipeline xmlns:p=""

   <p:variable name="product-name" select="'Fribble Widgets'" />

     <p:input port="source"><p:inline><product /></p:inline></p:input>
     <p:with-param name="product-name" select="$product-name" />
     <p:input port="stylesheet">
         <xsl:stylesheet version="1.0">
           <xsl:param name="product-name" />
           <xsl:template match="product">
             <product><xsl:value-of select="$product-name"/></product>


Or if you want to pass it as the value of an option, you could do  
something along the lines:

<p:pipeline xmlns:p="">

   <p:variable name="product-name" select="'Fribble Widgets'" />

   <p:add-attribute match="product" attribute-name="name">
     <p:input port="source"><p:inline><product /></p:inline></p:input>
     <p:with-option name="attribute-value" select="$product-name" />



Jeni Tennison

Received on Sunday, 14 December 2008 11:13:26 UTC