RE: Evaluating replace on string-replace

> -----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