RE: saxon:evaluate() (was: sorting and parameters)

Subject: RE: saxon:evaluate() (was: sorting and parameters)
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Tue, 18 Jan 2000 16:14:57 -0000
Steve Tinney: 
> Not quite, I think.  I was thinking of the case where $nodes is
> of type node-set, but $variable would be a string.

So was I.
> 
> So it won't support this (which is not to say it's not still extremely
> valuable):
> 
>   <xsl:variable name="nodes" select="nodeset($some-rtf)"/>
>   <xsl:variable name="newset" select="$nodes/some/$variable"/>
> 
I think it will do this, if I've understood what you're looking for. I
assume $variable holds an element name, e.g. "title", so 

   <xsl:variable name="variable" select="'title'"/>
   <xsl:variable name="path" select="concat('$nodes/some/', $variable)"/>

   <xsl:variable name="newset" select="saxon:evaluate($path)"/>

will have the same effect as 
   <xsl:variable name="newset" select="$nodes/some/title"/>

David Carlisle:

>but that case would presumably follow as the / operator takes
>a node set on the left and an xpath expression on the right so you'd
>presumably (?) be able to do
 
<xsl:variable name="newset" select="$nodes/some/saxon:evaluate($variable)"/>

No! The "/" operator is a very strange sort of operator because the thing on
its right is a Step, and a Step is essentially meaningless without the "/"
operator on its left (a Step on its own is just a shorthand for "./step").
"saxon:evaluate($variable)" is a function-call, not a Step, so the above
will be syntactically invalid. I'm introducing an extension function, not
changing the XPath syntax!

If we want a mathematical model of this thing I think a Step is actually a
function that maps a node-set to another node-set, so nodeset/step really
means step(nodeset). David's syntax would only make sense if steps were
first-class objects that could be stored in variables, returned by
functions, etc.

We have a language in which steps/functions are not first-class objects, but
we can get round the restrictions by introducing reflexion, i.e. allowing
expressions in the language to be generated and evaluated at run-time. We
can't have a variable whose value is a Step, but we can have a variable
whose value is a character string that can be parsed as a Step. 

I'm beginning to wonder whether this new function will generate more
perplexity than it is worth. If people can't cope with attribute value
templates, they're going to sink up to their necks in this one. Is the world
ready for reflexive languages? Still, I'm sure David will be there to help
them out!

Mike


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread