Using Javascript in Saxon


I'm trying to get the Saxon to use javascript in the XSL. I know this can be achieved in Xalan but I'm having difficulty to get it to work in Saxon. Does it requies BSF and Rhino setup on my local? I have them in my classpath but it is still not working. The following is the code I use. Have anybody done this before? Really appreciate for any suggestion. Thanks!



<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
      extension-element-prefixes="test saxon">

<saxon:script language="javascript" implements-prefix="test" src="">
   function greetings(user)
      return "Welcome to xxx " + user;

<xsl:template match="/">
   <xsl:value-of select="test:greetings('Mr. Bean')"/>


Who is Participating?
Geert BormansInformation ArchitectCommented:
Hi owonseed,

As far as I know you can't.
Unless this has recently changed, you can't use JavaScript for extensions in Saxon.
You can only use Java for that

If I am correct only Xalan and MSXML support javascript for extensions.

I recommend you ask Michael Kay directly.
He is on the biglist

Geert BormansInformation ArchitectCommented:

a reference would have been nice, no?
owonseedAuthor Commented:

Thanks for the tips. I've posted a new thread in the Saxon forum. I hope I can get a response from Michael Kay soon.

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Geert BormansInformation ArchitectCommented:
keep us posted here please
owonseedAuthor Commented:
I got the response from Michael Kay:

Read and respond to this message at:
By: mhkay

Javascript is not currently supported and I don't have any plans to do so. It could be done without changes to core Saxon code by writing a new ExtensionBinder, but I'm wary of doing things that involve potential dependencies and installation/configuration complications because they always generate a heavy support and testing load.


Geert BormansInformation ArchitectCommented:
mmh, that is what I thought.
Thanks for sharing the answer with us
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.