Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Problem calling functions from within XSLT?

From: "Craig Sanders" <cmsan1@-------.------.---.-->
To: NULL
Date: 1/13/2008 1:17:00 AM

Hello.

I hope someone can help. I can't for the life of me, seem to work out how to 
call functions from within XSLT code. I have a simple XSLT file (called 
function.xsl) which contains the following code ;

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
  version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<xsl:output
  method='html'
  version='1.0'
  encoding='UTF-8'
  indent='yes'/>


<xsl:template match="/">
    <html>
        <body>
            <xsl:if
              test="fn:base-uri()"
              xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
                XSLT function call succeeded.
            </xsl:if>
        </body>
  </html>
</xsl:template>
</xsl:stylesheet>

This code isn't meant to do anything useful - it is just the simplest piece 
of test code I could devise to try and distill the problem.

My corresponding XML file (which is called function.xml) resides in the same 
directory as the XSLT file and its contents are as follows ;

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="function.xsl"?>
<body>
</body>

When I attempt to load up this XML file into IE6 I get the following error ;

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and 
then click the Refresh button, or try again later.

Namespace 'http://www.w3.org/2005/02/xpath-functions' does not contain any 
functions.

When I load the XML file into the latest versions of Opera and Firefox, the 
diagnostic messages are even less helpful! They simply state that there was 
a problem processing the XSLT.

So then I installed Saxon version 9.0 Base. When I process the two files 
using Saxon I get the following error message ;

Error at xsl:if on line 21 of 
file:/D:/Documents%20and%20Settings/Craig%20Sanders/My%20Documents/xslt/function.xsl:
  XPST0017: XPath syntax error at char 13 on line 21 in {fn:base-uri()}:
    Cannot find a matching 0-argument function named
  {http://www.w3.org/2005/02/xpath-functions}base-uri()
Failed to compile stylesheet. 1 error detected.

Any help would be most appreciated. Thankyou. 




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent