Re: [xsl] xsl:function

Subject: Re: [xsl] xsl:function
From: Abel Braaksma <>
Date: Wed, 12 Sep 2007 09:18:47 +0200
XSLT is a language that can be run in a number of ways (just like any other language). If you want to run it from inside a browser, you can indeed do that, but you are stuck with XSLT 1.0 for the near foreseeable future.

However, browser based transformations are not easy and you have to know quite a bit of what is going on under the hood which makes it far from ideal for beginners (let alone the differences between browsers: subtle, but important).

If you want to learn XSLT, I recommend downloading Saxon. Use Saxon.NET if you want just a simple executable that you can run from within your favorite Integrated Development Environment. If you use Eclipse as IDE, I think it is more likely that Saxon for Java suites you better.

If for one reason or the other, you are stuck with using client side transformations, you can create non-portable functions using msxml:script. Search google for examples, but remember: it will only work in IE and it is not a recommended practice (IE7 has parsing scripts in XSLT off by default).

-- Abel Braaksma

Karanam.Chowdary@xxxxxxxxxxxxxxxxxx wrote:
What shud I do I m not using saxon and I m not running in cmd prompt. I
hv just written XSL code in text file and saved it as .xsl and directly
opening XML in browser. I really donno wat processor it is. Shud I
install sum processor(s/w). SAXON? I m just cing the results in IE not
cmd prompt. If I download saxon as u suggested can I get the results in
browser? And how shud I run that?

-----Original Message-----
From: Abel Braaksma [] Sent: Wednesday, September 12, 2007 12:30 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] xsl:function

I just completed your code bit and changed the obvious xsl:result error into xsl:value-of. But that was not the error you got. I ran it, and it put out "2".

<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet xmlns:xsl="";
version="2.0" xmlns:xs="";
xmlns:my="http://whatever"; exclude-result-prefixes="my">
<xsl:function name="my:one">
<xsl:param name="a"/>
<xsl:param name="b"/>
<xsl:value-of select="$a+$b"/>
<xsl:template match="/">
<xsl:value-of select="my:one(1,1)"/>

What I think is that you accidentally ran an XSLT 2.0 stylesheet with an

XSLT 1.0 processor (which should already complain about the xsl:function

instruction, but perhaps first throws an error about the extension functions not being known. Saxon for instance says there's no known java


-- Abel Braaksma

Current Thread