W3C home > Mailing lists > Public > public-xml-processing-model-wg@w3.org > April 2007

Proposed component: p:string-replace

From: Norman Walsh <ndw@nwalsh.com>
Date: Mon, 23 Apr 2007 10:31:05 -0400
To: public-xml-processing-model-wg@w3.org
Message-ID: <87irbnw4ba.fsf@nwalsh.com>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:21:50 GMT