Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Problem with EXSLT functions using 4xslt

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 8/2/2005 2:11:00 PM

Prashanth Ellina wrote:


> When I try to run the following xsl on an xml with "<dummy></dummy>",
> the 4xslt processor says "Undefined function: "testfn"". Any ideas?
> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                 xmlns:exslt = "http://exslt.org/common"
>                 xmlns:func = "http://exslt.org/functions"
>                 version="1.0">
> 
> <xsl:template match="/">
>      <xsl:value-of select="testfn()"/>
> </xsl:template>
> 
> <func:function name="testfn">
>      <func:result>
>      <hello></hello>
>      </func:result>
> </func:function>
> 
> </xsl:stylesheet>

I don't use 4xslt but Saxon 6 also has support for the EXSLT functions, 
here is a stylesheet that I think achieves what you want to do:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:func="http://exslt.org/functions"
                 xmlns:myfunctions="http://example.com/2005/08/functions"
                 extension-element-prefixes="func"
                 version="1.0">

<xsl:template match="/">
   <results>
      <xsl:copy-of select="myfunctions:testfn()"/>
   </results>
</xsl:template>

<func:function name="myfunctions:testfn">
      <func:result>
      <hello></hello>
      </func:result>
</func:function>

</xsl:stylesheet>

The result of that stylesheet run against any source document is

<?xml version="1.0" encoding="utf-8"?>
<results 
xmlns:myfunctions="http://example.com/2005/08/functions"><hello/></results>

So you need to make sure that you
   - define your own functions in a namespace
   - have extension-element-prefixes="func" on the <xsl:stylesheet>
   - be aware that an EXSLT function defined with func:function like the
     testfn returns a nodeset, if you want to have a nodeset show up in
     the result tree you need to use xsl:copy-of on the result of the
     function call


-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Like It
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