[xsl] Help creating and calling xsl:functions

Subject: [xsl] Help creating and calling xsl:functions
From: "William Scarvie" <wscarvie@xxxxxxxxxxx>
Date: Fri, 31 Mar 2006 09:45:29 -0800
Hi all,

I'm having trouble getting even basic uses of xsl:function to work in my browsers. I'm using this sample code, from http://www.xml.com/lpt/a/2003/09/03/trxml.html:

<xsl:stylesheet version="2.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:foo="http://whatever";>

<!-- Compare two strings ignoring case, returning same
values as compare(). -->
<xsl:function name="foo:compareCI">
<xsl:param name="string1"/>
<xsl:param name="string2"/>
<xsl:value-of select="compare(upper-case($string1),upper-case($string2))"/>
</xsl:function>


 <xsl:template match="/">
compareCI red,blue: <xsl:value-of select="foo:compareCI('red','blue')"/>
compareCI red,red: <xsl:value-of select="foo:compareCI('red','red')"/>
compareCI red,Red: <xsl:value-of select="foo:compareCI('red','Red')"/>
compareCI red,Yellow: <xsl:value-of select="foo:compareCI('red','Yellow')"/>
 </xsl:template>

</xsl:stylesheet>

I create a "dummy" XML document, using this stylesheet, as follows:

<?xml version="1.0" ?>

<?xml-stylesheet type="text/xsl" href="fn_test.xsl" ?>

<test_tag>Nothing to see here</test_tag>

When using Firefox 1.5.0.1, I get the following error when I try to open the XML file in the browser:

Error during XSLT transformation: An unknown XPath extension function was called.

When using IE 6.0, I get the following error:

Namespace 'http://whatever' does not contain any functions.

Any idea why I'm not getting function calls to work?

Thanks in advance,

Will

Current Thread