473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with EXSLT functions using 4xslt

Hi,

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>

Thanks in advance,
Prashanth

Aug 2 '05 #1
2 1413


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/
Aug 2 '05 #2
> 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


Wow! It works! Thank you :)

Aug 2 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: anon | last post by:
So I've encountered a strange behavior that I'm hoping someone can fill me in on. i've written a simple handler that works with one small exception, when the parser encounters a line with '&' in...
0
by: Andy Fish | last post by:
Hi I am using Xalan-J 2.4.1 and I am trying to get the EXSLT node-set function working. xalan:nodeset() works fine but when I try exslt:node-set I get this error: (Location of error...
0
by: Chris Croughton | last post by:
I'm trying to use the EXSLT regexp package from http://www.exslt.org/regexp/functions/match/index.html (specifically the match function) with the libxml xltproc (which supports EXSLT), but...
0
by: Chris | last post by:
Can someone point me the right way? I'm trying to use the date/time extensions but with little luck. Here's what I've got: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0"...
0
by: Anders Borum | last post by:
Hello! Just wanted to point your interest to this great article on EXSLT. It seems like some of the people in this newsgroup are really busy :-) ...
0
by: Nicolas | last post by:
Hi, I've been working on this problem for a couple of days and now i have no more ideas. first, this problem only happens with jdk 1.5, everything was fine with jdk1.4. I'm using a...
1
by: will | last post by:
All Hope you can help with the following.. I am using recursion to calculate the sum of DEBT_INPUT_VALUE_BEFORE_SPLIT * CTXR_TAX_RATE elements, along the lines of sum(a*b) ie
6
by: Christoph | last post by:
I'm trying to come up with a stylesheet where, when the rows are displayed, duplicate game names are not shown on subsequent rows. It works but doesn't work properly. If I sort the data using...
3
by: Petterson Mikael | last post by:
Hi, I was running the following in Netbeans 5.5: sing com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl - default JRE XSLT processor. Creating output/NcmiSigTest.java Unsupported...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.