W3C home > Mailing lists > Public > xsl-editors@w3.org > July to September 2001

"Dynamic" XPath expressions

From: Peter Marks <petermarks@blueyonder.co.uk>
Date: Tue, 28 Aug 2001 19:41:11 -0400 (EDT)
Message-ID: <000701c1301a$ec0de0e0$b29d1e3e@trouble>
To: <xsl-editors@w3.org>
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}"/>

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

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

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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:44:21 UTC