You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by sagara Gunathunga <sa...@aeturnum.com> on 2007/12/13 09:06:43 UTC
Xalan error with XSLT functions
Hi all ,
I have several question regarding the XSLT 2 custom function handling
with Xalan and XSLTC . I used latest Xalan 2.7.1 distribution build on
27- Nov 2007 .
1.
First ,I tried to transform ext.xsl [1] file using flowing codes .
/ TransformerFactory transformerFactory =
TransformerFactory.newInstance()
Transformer transformer =
transformerFactory.newTransformer(*new*
StreamSource("pre/ext1.xsl"));
transformer.transform(*new* StreamSource("pre/ext.xml"),
*new*
StreamResult(System.out//))/;
I got following 2 errors :
/(Location of error _unknown)java.lang.NoSuchMethodException_: For
extension function,
could not find method foo.add([ExpressionContext,] #NUMBER,
#NUMBER).Checked both static and instance methods.
/
/ (Location of error _unknown)java.lang.NoSuchMethodException_: For
extension function, could not find
method foo.Hello([ExpressionContext,] #STRING).Checked both static
and instance methods./
2. Then , tried to Pre-compile ext.xsl file using XSLTC using
following code segment .
It didn't produce any errors but class file was not generated.
/ XSLTC xsltc = *new* XSLTC();
xsltc.init();
xsltc.setDestDirectory("bin");
xsltc.setDebug(*true*);
xsltc.setClassName("ext");
FileInputStream in =*new* FileInputStream("pre/ext1.xsl");
xsltc.compile(in,"ext");/
please help me to solve these issues , specially 2^nd one is more
important to me .
Thanks
Sagara
[1) ext.xsl
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
extension-element-prefixes="foo" xmlns:foo="foo">
<xsl:function name="foo:add">
<xsl:param name="int1"/>
<xsl:param name="int2"/>
<xsl:value-of select="$int1+$int2"/>
</xsl:function>
<xsl:function name="foo:Hello" as="xs:string">
<xsl:param name="sentence" as="xs:string"/>
<xsl:value-of select="$sentence" />
</xsl:function>
<xsl:template match="/">
the value is : <xsl:value-of select="foo:add(3,4)"/>
<xsl:value-of select="foo:Hello(' parameter')"/>
</xsl:stylesheet>
Re: Xalan error with XSLT functions
Posted by Henry Zongaro <zo...@ca.ibm.com>.
Hi, Sagara.
sagara Gunathunga <sa...@aeturnum.com> wrote on 2007-12-13 03:06:43 AM:
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> extension-element-prefixes="foo" xmlns:foo="foo">
>
> <xsl:function name="foo:add">
> <xsl:param name="int1"/>
> <xsl:param name="int2"/>
> <xsl:value-of select="$int1+$int2"/>
> </xsl:function>
>
> <xsl:function name="foo:Hello" as="xs:string">
> <xsl:param name="sentence" as="xs:string"/>
> <xsl:value-of select="$sentence" />
> </xsl:function>
>
>
> <xsl:template match="/">
> the value is : <xsl:value-of select="foo:add(3,4)"/>
> <xsl:value-of select="foo:Hello(' parameter')"/>
>
>
> </xsl:stylesheet>
>
> I got following 2 errors :
>
> /(Location of error _unknown)java.lang.NoSuchMethodException_: For
> extension function,
> could not find method foo.add([ExpressionContext,] #NUMBER,
> #NUMBER).Checked both static and instance methods.
> /
>
> / (Location of error _unknown)java.lang.NoSuchMethodException_: For
> extension function, could not find
> method foo.Hello([ExpressionContext,] #STRING).Checked both static
> and instance methods./
That's because your stylesheet is using the XSLT 2.0 stylesheet function
feature. The Xalan-Java processors support only XSLT 1.0, so they attempt
to process your stylesheet in forwards compatibility mode.
Thanks,
Henry
------------------------------------------------------------------
Henry Zongaro XSLT Processors Development
IBM SWS Toronto Lab T/L 313-6044; Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com