W3C home > Mailing lists > Public > xproc-dev@w3.org > December 2008

Re: using p:variable

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sun, 14 Dec 2008 11:12:49 +0000
Cc: "XProc Dev" <xproc-dev@w3.org>
Message-Id: <0A3484BA-5D78-4DD3-BD76-D2CD3AFDB443@jenitennison.com>
To: "Dave Pawson" <dave.pawson@gmail.com>


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="http://www.w3.org/ns/xproc"

   <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="http://www.w3.org/ns/xproc">

   <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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:03:04 UTC