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

Re: using p:variable

From: mozer <xmlizer@gmail.com>
Date: Mon, 29 Dec 2008 14:07:22 +0100
Message-ID: <21d9ade60812290507s40d11de9xfe1ac94fb4b8f440@mail.gmail.com>
To: "Norman Walsh" <ndw@nwalsh.com>
Cc: "XProc Dev" <xproc-dev@w3.org>
Hi,
Just one minor point, this example relies on XPath 2.0 Functions
(fn:replace)

Xmlizer

On Mon, Dec 15, 2008 at 3:39 AM, Norman Walsh <ndw@nwalsh.com> wrote:

> 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"
>                xmlns:c="http://www.w3.org/ns/xproc-step"
>                xmlns:ex="http://example.com/ns/xproc-example"
>                 xmlns:p="http://www.w3.org/ns/xproc"
>                 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:inline><c:result>text</c:result></p:inline>
>   </p:input>
>  <p:with-option name="replace"
>    select="concat('&quot;',
>                    replace($value, '&quot;', '&quot;&quot;'),
>                   '&quot;')">
>    <p:empty/>
>  </p:with-option>
> </p:string-replace>
>
> </p:declare-step>
>
> and here's an example of how to use it:
>
> <p:pipeline name="pipeline"
>            xmlns:ex="http://example.com/ns/xproc-example"
>             xmlns:p="http://www.w3.org/ns/xproc">
>
> <p:import href="set-value.xpl"/>
>
> <p:variable name="some-string" select="'my &quot;value'"/>
>
> <ex:set-value>
>  <p:with-option name="value" select="$some-string"/>
> </ex:set-value>
>
> </p:pipeline>
>
>                                        Be seeing you,
>                                          norm
>
> --
> 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, 29 December 2008 13:08:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 29 December 2008 13:08:04 GMT