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

Re: Since xsl:script and xsl:eval are not recommended, so is t


xsl eval
Hi Collin,

> Since xsl:script and xsl:eval are not recommended, so is there other
> equavalent meahanism provided in XSL?

I guess that by xsl:script and xsl:eval you're talking about the
elements in WD-xsl?

In WD-xsl, xsl:script is used to define functions using a scripting
language. There's no standard way of doing this in XSLT 1.0, but most
XSLT processors support something like it using an extension. In
MSXML, for example, you can use msxsl:script in almost exactly the
same way as you could use xsl:script. The major difference from WD-xsl
is that all such functions have to be *extension* functions, which
means that they have to be in a namespace.

If you're using something other than MSXML, I recommend using
func:function from EXSLT (http://www.exslt.org/func) to define the
extension function using XSLT code rather than JavaScript, not least
because there will be a built-in method for doing that (xsl:function)
in XSLT 2.0. JavaScript is a very tempting get out for when you can't
work out how to do something using XSLT, but it's more portable and
better practice to use XSLT for the code. (Of course there are things
that XSLT can't do, such as get the system time, or would require
reams of code to support, such as regular expressions, but most of the
time I see people using JavaScript in XSLT it's to do things that they
could do using XSLT.)

As far as xsl:eval is concerned, once you've declared an extension
function, you can call it just like you can any other function. For
example, rather than:

  <xsl:eval>myFunction()</xsl:eval>

you should use:

  <xsl:value-of select="my:function()" />

If you have specific questions about XSLT, I heartily recommend the
XSL-List -- http://www.mulberrytech.com/xsl/xsl-list -- as a place to
ask them.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.