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

Re: using p:variable

From: Dave Pawson <dave.pawson@gmail.com>
Date: Sun, 14 Dec 2008 13:59:32 +0000
Message-ID: <711a73df0812140559r5dc4b02cobc46e1d94976ad4b@mail.gmail.com>
To: "XProc Dev" <xproc-dev@w3.org>

2008/12/14 Jeni Tennison <jeni@jenitennison.com>:

> I think the easiest way to do it is with XSLT of the kind I gave you in the
> previous example. There's no standard step that I can see for "replace the
> content of an element with a string", which is essentially what you need to
> do to create an element from a string.

I'm coming round to that way of thinking!


>
> You could use p:string-replace:
>
> <p:pipeline xmlns:p="http://www.w3.org/ns/xproc">
>
>  <p:variable name="product-name" select="'Fribble Widgets'" />
>
>  <p:string-replace match="product/text()">
>    <p:input port="source">
>      <p:inline>
>        <product>product-name</product>
>      </p:inline>
>    </p:input>
>    <p:with-option name="replace"
>      select="concat('&quot;',
>                     replace($product-name, '&quot;', '&quot;&quot;'),
>                     '&quot;')" />
>  </p:string-replace>
>
> </p:pipeline>
>
> but the p:with-option there isn't pretty, because the value of the replace
> option is an XPath expression, so to create a (quoted) string from the value
> you have in the $product-name variable, you need to concatenate some quotes
> and then make sure you escape any quotes in the value of the $produce-name
> variable.

Quote hell! That's even worse than  the test suite!

I'm basing my tests on
http://tests.xproc.org/tests/required/system-property-001.xml

So I have
<declare-step

lots of <replace-strings/>

So I can't even fit a p:variable in!




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

Or something that would allow that simple step,
create an element with this name?

Or perhaps as you say, XSLT can do that... why
re-invent the wheel!

regards



-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk
Received on Sunday, 14 December 2008 14:00:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 14 December 2008 14:00:07 GMT