W3C home > Mailing lists > Public > public-xml-processing-model-comments@w3.org > November 2008

Evaluating replace on string-replace

From: Norman Walsh <ndw@nwalsh.com>
Date: Mon, 03 Nov 2008 20:55:28 -0500
To: public-xml-processing-model-comments@w3.org
Message-ID: <m23ai8tfu7.fsf@nwalsh.com>
Consider this pipeline fragment:

  <p:variable name="opos" select="p:iteration-position()"/>
    <p:iteration-source select="//div"/>
    <p:string-replace match="/div/@a" replace="3+4"/>

For each matched /div/@a, the replacement expression "3+4" is evaluated,
producing 7 and the string value of @a becomes "7".

Makes sense.

Now consider:

  <p:variable name="opos" select="p:iteration-position()"/>
    <p:iteration-source select="//div"/>
    <p:string-replace match="/div/@a">
      <p:with-option name="replace"

This is the moral equivalent of (for the first iteration of each loop,
at least), replace="1,1"

If you evaluate "1,1" you get...a sequence of two 1's. That's either
an error or the result is @a="11" (or maybe "1 1").

Which of those is the right answer?

The poor, naive user probably expected @a="1,1". AFAICT, in order
to get that, he or she has to write:

<p:with-option name="replace"

which works, but seems surprising.

Did my analysis go off the rails somewhere?

                                        Be seeing you,

Norman Walsh <ndw@nwalsh.com> | Some people do their laundry in emacs,
http://nwalsh.com/            | but I find typing ^C-^X-^W-q-L-TT to
                              | add the fabric softener to be a bit
                              | cumbersome.-- rlr@panix.com

Received on Tuesday, 4 November 2008 01:56:45 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:28:26 UTC