Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2011, 02:48 PM
Authorized User
 
Join Date: Apr 2008
Posts: 70
Thanks: 17
Thanked 1 Time in 1 Post
Send a message via Yahoo to iceandrews
Default Using EXSLT - dyn:evaluate

We have a situation where we'd like to use dyn:evaluate() from the EXSLT extention function library, but we can't seem to get anything to work. We are using Saxon 8.9 in house, but in order to remain processor agnostic and portable, we wanted didn't want to use the saxon:evaluate() function.

We've reviewed all the documentation on the exslt.org website surround th dyn:evaluate() function, but there's no third party implementations of this function to use. (plus some of the zip packages are corrupt in the dynamic area of the EXSLT website.)

As a last resort, we can use saxon:evaluate(), but that will cause additional work for us down the road. We planned on using this transformation as part of a stand alone application that's being built on .NET as well, and obviously if we can make processor independent, it would integrate seamlessly there.

Any suggestions on how to get dyn:evaluate to work, or is there another alternative that would need those basics needs.

Thanks!
 
Old February 15th, 2011, 04:24 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

There are various things in XSLT which might help, but none is a easy solution.

Firstly, Saxon is available in .Net as well as Java, so you might consider restricting your targets to Saxon only. This would also give you the ability to use XSLT 2.0, which is a big improvement over XSLT 1.0 If this really isn't an option then you will need to code against this.

One way would be to write your own extension method in .Net, and then write some simple XSLT, using the function-available() function to determine if one of the three options is available.

Code:
<xsl:choose>
<xsl:when test="function-available('saxon:evaluate')">
  <xsl:value-of select="saxon:evaluate($xpath)"/>
</xsl:when>
<xsl:when test="function-available('dyn:evaluate')">
  <xsl:value-of select="dyn:evaluate($xpath)"/>
</xsl:when>
<xsl:when test="function-available('myext:evaluate')">
  <xsl:value-of select="dyn:evaluate($xpath)"/>
</xsl:when>
<xsl:otherwise>
  <xsl:message terminate="yes">Unsupported XSLT processor.</xsl:message>
</xsl:otherwise>
</xsl:when>
Basic implementations of evaluate in C# can be found here: http://stackoverflow.com/questions/2...piledtransform. Others may exist, I didn't look for long.

Another final option is to explain how you want to use the evaluate() function, and maybe there is actually a way to do this without using evaluate() at all.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
iceandrews (February 15th, 2011)
 
Old February 15th, 2011, 05:01 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The reason Saxon doesn't implement dyn:evaluate is its insistence on making the variables from the expression context available for use within the expression - this means that it's impossible to optimize variables at compile time because you don't know statically where all the references are; this was too high a price to pay. So saxon:evaluate has a mechanism for explicit passing of parameters instead.

If you're not using variables or dependent on other parts of the context, then it's easy to write an xsl:function called dyn:evaluate that wraps a call on saxon:evaluate; or you can write code that calls either saxon:evaluate() or dyn:evaluate() based on the result of function-available().
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
iceandrews (February 15th, 2011)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help in EXSLT function str:tokenize priby XSLT 2 September 1st, 2009 01:43 AM
help - EXSLT func cannot set more than one result! anboss XSLT 1 October 28th, 2008 02:17 PM
selecting param dyn. by variable polarbear XSLT 1 January 19th, 2008 09:03 AM
I want to Create a Dyn. .Input Matrix Of Textboxes sanchit_mum07 C# 0 September 12th, 2007 09:58 AM
string to x-path - EXSLT - dynamic functions Geierwally XSLT 1 July 12th, 2007 10:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.