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>

Dave,

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"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   exclude-inline-prefixes="xsl">

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

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

</p:pipeline>

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" />
   </p:add-attribute>

</p:pipeline>

Cheers,

Jeni
-- 
Jeni Tennison
http://www.jenitennison.com
Received on Sunday, 14 December 2008 11:13:26 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 14 December 2008 11:13:26 GMT