Re: Here's a tricky one

/ Alessandro Vernet <avernet@orbeon.com> was heard to say:
| On 5/11/07, Norman Walsh <ndw@nwalsh.com> wrote:
|> Assuming that $p:episode is "7ffa7ffa" when this pipeline is executed,
|> what is the output?
|>
|>   <p:option name="match" value="@episode"/>
|>   <p:option name="replace" select="$p:episode"/>
|
| The way I read the spec, 'replace' is an XPath expression and it is
| evaluated in the context of the matching node. The '7ffa7ffa' XPath
| expression will return an empty nodeset in the context of an
| attribute, and its string value will be an empty string. So the value
| of the '@episode' attribute is set to an empty string.

Yes. That's the tricky bit. Because I'm thinking about using XPath,
I naturally type "select=" for the value. But that means it gets
evaluated *twice*.

In fact, the pipeline I provided doesn't run at all because
"7ffa7ffa" isn't a valid XPath expression.

Which is lucky because I think it would have taken even longer to
debug if it had run successfully but produced '' as the value!

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | A man is not necessarily intelligent
http://nwalsh.com/            | because he has plenty of ideas, any
                              | more than he is a good general because
                              | he has plenty of soldiers.-- Chamfort

Received on Friday, 11 May 2007 16:22:19 UTC