[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] making dynamic evaluation via xsl:evaluate more dynamic
Subject: RE: [xsl] making dynamic evaluation via xsl:evaluate more dynamic From: Jakub Malý <jakub@xxxxxxx> Date: Wed, 18 Apr 2012 00:11:58 +0200 |
What you suggest, Phil, seems like a nice workaround. As for the previous post: There is some static analysis going on in when xsl:evaluate is used? I thought it works somehow like this: When xsl:evaluate is encountered, the value passed to xpath attribute is passed to the XPath parser together with the names of free variables used in the expression (collected from the with-param instructions). The expression is parsed, variables are bound to the values provided by with-param and evaluated. I thought the whole process would not have to change very much, only the attribute name of each with-param will now be evaluated similarly as in e.g. xsl:element name="...", allowing attribute value template. > -----Original Message----- > From: Philip Fearon [mailto:pgfearo@xxxxxxxxxxxxxx] > Sent: Tuesday, April 17, 2012 11:51 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: [xsl] making dynamic evaluation via xsl:evaluate more dynamic > > Just a thought - now XPath 3.0 has the Let Expression, wouldn't it be possible > to safely wrap the XPath string with a Let Expression that declares the > dynamic variables - before passing this as a parameter to xsl:evaluate? > > Phil > > 2012/4/17 Michael Kay <mike@xxxxxxxxxxxx>: > > By all means raise this feedback with the XSL WG. The best way to do > > so is via the W3C bugzilla system - that's the way the WGs manage their > agenda. > > > > I think the answer is that no-one has previously suggested a need for > > this feature. It strikes me as raising a lot of questions. In your use > > case, how do you find out what external variables the XPath expression > > uses, so that you can bind the right names? If you don't know the > > names statically, you presumably need some way to discover them > > dynamically. But then, knowing the names of the parameters isn't much > > use if you don't know their semantics; where does this knowledge come > from? > > > > Michael Kay > > Saxonica > > > > > > On 17/04/2012 18:53, Jakub Mal} wrote: > >> > >> Hello, > >> the new instruction evaluate allows for dynamic evaluation of > >> expressions in stylesheets. > >> This: > >> <xsl:evaluate xpath="'1 + 1'"> > >> </xsl:evaluate> > >> Returns 2 > >> > >> All variables in the evaluated expression must be bound using > >> with-param, like in <xsl:evaluate xpath="'$p1 + $p2'"> > >> <xsl:with-param name="p1" select="1" /> > >> <xsl:with-param name="p2" select="2" /> </xsl:evaluate> Which > >> returns 3. > >> > >> The syntactic rules for with-param are I think the same as in the > >> case of call-template. Aren't those unnecessarily restrictive in this case? > >> I suppose (please correct me, if I am wrong) the cost of dynamic > >> evaluation would not change much, if attribute value template was > >> allowed for the attribute name of with-param in evaluate, such e.g.: > >> <xsl:evaluate xpath="'$p1 + $p2'"> > >> <xsl:with-param name="{'p' || '1'}" select="1" /> > >> <xsl:with-param name="{'p' || '2'}" select="2" /> </xsl:evaluate> > >> > >> Did this question arise when semantics of evaluate was discussed? > >> I have encountered an application where this would come in handy > >> (well, it would provide an alternative solution to a problem which I > >> solved differently), so maybe those applications that require dynamic > >> evaluation would appreciate it as well. I was a bit surprised that it > >> is not possible, because it feels appropriate to me. When dealing > >> with dynamic evaluation, why not let the names of variables to by > >> dynamic as well? > >> > >> Jakub Maly. > >> http://www.xrg.cz
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] making dynamic evaluation, Philip Fearon | Thread | [xsl] WAI-ARIA class?, Craig Sampson |
Re: [xsl] making dynamic evaluation, Philip Fearon | Date | Re: [xsl] Haskell programmer's rant, Alan Painter |
Month |