"Dynamic" XPath expressions

I was looking for a way to do a mach against a dynamically constructed XPath
expression, something like:

<xsl:param name="itemFilter" select="'[@quantity > 10]'"/>

<xsl:template match="/">
    <xsl:apply-templates select="item{itemFilter}"/>
</xsl:template>
...

I could not find any way to do this kind of XPath expression. Sure there are
other ways to build this filter (I think you could use a key), but this is a
simple case; I could imagine much more complicated examples, where I would
want to pass XPath expressions to evaluate in a context other than that in
which they are written.

In the XSL 2.0 requirements, I saw the following:

> 2.18 Could Make Coercions Symmetric By Allowing Scalar to Nodeset
Conversion

> Presently, no datatype can be coerced or cast to a node-set. By allowing a
string value > to convert to a node-set, some user "gotchas" could be
avoided due.

This seems like it may do the trick, but the motivation is very different. I
wonder whether string coercion or an extension of the attribute value
template mechanism is better. The latter is more explicit. Which would be
easier to implement?

Any thoughts?

Peter

Received on Wednesday, 12 September 2001 10:34:19 UTC