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

Re: using p:variable

From: Norman Walsh <ndw@nwalsh.com>
Date: Sun, 14 Dec 2008 21:39:50 -0500
To: XProc Dev <xproc-dev@w3.org>
Message-ID: <m21vwajh55.fsf@nwalsh.com>
Jeni Tennison <jeni@jenitennison.com> writes:
>     <p:with-option name="replace"
>       select="concat('&quot;',
>                      replace($product-name, '&quot;', '&quot;&quot;'),
>                      '&quot;')" />

Ooh! Bonus points to Jeni for handling the case where the replacement text
contains a double quote! :-)

> Maybe there'd be a use for a p:set-value step. I don't know.

You can certainly write your own. And I'm happy to add it to exproc.org if
there's interest.

Here's set-value.xpl:

<p:declare-step type="ex:set-value"
		exclude-inline-prefixes="c ex p">
<p:output port="result"/>

<p:option name="value" required="true"/>

<p:string-replace match="c:result/text()">
  <p:input port="source">
  <p:with-option name="replace"
                   replace($value, '&quot;', '&quot;&quot;'),


and here's an example of how to use it:

<p:pipeline name="pipeline"

<p:import href="set-value.xpl"/>

<p:variable name="some-string" select="'my &quot;value'"/>

  <p:with-option name="value" select="$some-string"/>


                                        Be seeing you,

Norman Walsh <ndw@nwalsh.com> | They that can give up essential liberty
http://nwalsh.com/            | to obtain a little temporary safety
                              | deserve neither liberty nor
                              | safety.--Benjamin Franklin

Received on Monday, 15 December 2008 02:40:30 UTC

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