Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Problem with EXSLT functions using 4xslt >Thread Next - Re: Problem with EXSLT functions using 4xslt Re: Problem with EXSLT functions using 4xsltTo: 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/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
