Subject: Re: [xsl] FXPath v0.3 + SAXON Implementation From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 8 Mar 2001 13:43:34 +0000 |
Hi Dave, > com:eval is fooling me. My fault. There's perhaps more description in EXSLT - Functions at http://www.jenitennison.com/xslt/exslt/functions/#function-com:eval. Basically the implementation with EXSLT and with FXPath are hacks because there's no support for dynamic evaluation of expressions in XSLT. > It transpires that it results in a template match, moded, with an > expression as a param. > > so I have > > <xsl:template match="*" mode="com:eval"> > <xsl:param name="expr" select="."/> > ????? > </xsl:template> > > I'm *guessing* that the function evaluates to the application > of the expression to the node value. That's the point of com:eval(), but it'll only work with the EXSLT and FXPath implementations if you provide some support for it in the form of a moded template. Because there's no dynamic evaluation of expressions in XSLT, the only way to support the function is to convert the expressions yourself. So, if you're going to use com:eval() on a load of nodes with a particular expression then you should write a template to support it: <xsl:template match="node()|@*" mode="com:eval"> <xsl:param name="expr" select="'.'" /> <xsl:choose> <xsl:when test="$expr = 'contains(., "P")'"> <xsl:value-of select="contains(., 'P')" /> </xsl:when> <xsl:when test="$expr = 'starts-with(., "foo")'"> <xsl:value-of select="starts-with(., 'foo')" /> </xsl:when> ... <xsl:otherwise> <xsl:value-of select="." /> </xsl:otherwise> </xsl:choose> </xsl:template> Of course if you're using a processor that supports dynamic evaluation of expressions in XSLT then you can use a function from that processor to do the work for you: <xsl:template match="node()|@*" mode="com:eval"> <xsl:param name="expr" select="'.'" /> <xsl:choose> <xsl:when test="function-available('saxon:evaluate')"> <xsl:value-of select="saxon:evaluate($expr)" /> </xsl:when> ... <xsl:otherwise> <xsl:value-of select="." /> </xsl:otherwise> </xsl:choose> </xsl:template> But you might be better off just using that function rather than going through com:eval() in the first place. I hope that clears things up a bit? Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] FXPath v0.3 + SAXON Imple, David Rosenborg | Thread | [xsl] Re: paging question, Dimitre Novatchev |
Re: [xsl] FXPath v0.3 + SAXON Imple, David Rosenborg | Date | Re: [xsl] [Ann] jd.xslt - a XSLT 1., Sebastian Rahtz |
Month |