Proposed component: p:string-replace

I propose the following component for our standard library:

  <p:declare-step type="p:string-replace">
    <p:input port="source" sequence="no"/>
    <p:output port="result" sequence="no"/>
    <p:option name="match" required="yes"/>
    <p:option name="replace" required="yes"/>
  </p:declare-step>

This step searches for nodes that match the XPath match pattern in the
"match" option and replaces the string value of the matched node with
the value of the replace option. The replace option is an XPath 1.0
expression that will be evaluated with the context node set to the
matching node and the XPath variable $p:string set to the original
value of the node.

For example, this would replace the name of the p:identity step
named 'foo' with 'FOO'.

<px:string-replace>
  <p:option name="match" value="p:identity[@name='foo']/@name"/>
  <p:option name="replace" value="translate($p:string,'abcdefghijklmnopqrstuvwyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
</px:string-replace>

If the match expression matches a node which has element children,
they'll all be replaced by the single text node that results from
evaluating the replace expression on the string value of the node.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | Everything should be made as simple as
http://nwalsh.com/            | possible, but no simpler.

Received on Monday, 23 April 2007 14:31:26 UTC