Re: using p:variable

2008/12/14 Jeni Tennison <>:

> 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="">
>  <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

So I have

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!


Dave Pawson
Docbook FAQ.

Received on Sunday, 14 December 2008 14:00:07 UTC