- From: Dave Pawson <dave.pawson@gmail.com>
- Date: Sun, 14 Dec 2008 13:59:32 +0000
- 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('"',
> replace($product-name, '"', '""'),
> '"')" />
> </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 UTC