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

RE: Evaluating replace on string-replace

From: <Toman_Vojtech@emc.com>
Date: Tue, 4 Nov 2008 02:46:01 -0500
Message-ID: <6E216CCE0679B5489A61125D0EFEC7870D4CA7E2@CORPUSMX10A.corp.emc.com>
To: <public-xml-processing-model-comments@w3.org>

> -----Original Message-----
> From: public-xml-processing-model-comments-request@w3.org 
> [mailto:public-xml-processing-model-comments-request@w3.org] 
> On Behalf Of Norman Walsh
> Sent: Tuesday, November 04, 2008 2:55 AM
> To: public-xml-processing-model-comments@w3.org
> Subject: Evaluating replace on string-replace
> 
> Consider this pipeline fragment:
> 
> <p:for-each>
>   <p:variable name="opos" select="p:iteration-position()"/>
>   <p:for-each>
>     <p:iteration-source select="//div"/>
>     <p:string-replace match="/div/@a" replace="3+4"/>
>   </p:for-each>
> </p:for-each>
> 
> 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:for-each>
>   <p:variable name="opos" select="p:iteration-position()"/>
>   <p:for-each>
>     <p:iteration-source select="//div"/>
>     <p:string-replace match="/div/@a">
>       <p:with-option name="replace"
> 		     select="concat($opos,',',p:iteration-position())"/>
>     </p:string-replace>
>   </p:for-each>
> </p:for-each>
> 
> 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?

In our (XPath 1.0 based implementation), replace equal to "1,1" produces
an XPath error. I am not sure what the behavior would be with an XPath
2.0 implementation.

Regards,
Vojtech
Received on Tuesday, 4 November 2008 07:46:57 UTC

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