OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Since xsl:script and xsl:eval are not recommended, so is t

[ Lists Home | Date Index | Thread Index ]

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/





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS