[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: FXPath v0.3 + SAXON Implementation

Subject: Re: FXPath v0.3 + SAXON Implementation
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 8 Mar 2001 13:43:34 +0000
saxon dynamic evaluation
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(., &quot;P&quot;)'">
         <xsl:value-of select="contains(., 'P')" />
      </xsl:when>
      <xsl:when test="$expr = 'starts-with(., &quot;foo&quot;)'">
         <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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.