cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Norman Barker <norm...@comsine.co.uk>
Subject Re: Extension functions in XSL (Saxon)
Date Fri, 19 Nov 2004 12:00:49 GMT
Derek Hohls wrote:

>I am running Cocoon 2.1.5 under Windows XP, Java 1.4.2
>
>I have the following test files:
>
>math.xml
><?xml version="1.0" encoding="UTF-8"?>
><root>
>  <number>42</number>
></root>
>
>math.xsl
><?xml version="1.0"?> 
><xsl:stylesheet
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  xmlns:math="java:java.lang.Math"
>  version="1.0">
>
><xsl:template match="/">
>  <xsl:value-of  select="math:max(5,10)"/>
>  *
>  <xsl:value-of  select="math:cos(100)"/>
></xsl:template>
> 
></xsl:stylesheet>  
>
>when I run this through Saxon  on the command line,
>I get :
>
>test.xml
><?xml version="1.0" encoding="utf-8"?>10
>*
>0.8623188722876839
>
>but when I try the same process under Cocoon, I get:
>
>org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
>java.lang.RuntimeException: java.lang.NoSuchMethodException: For
>extension function, could not find method
>java.lang.Double.max([ExpressionContext,] #NUMBER).
>
>Any ideas how to get extension functions like this to work?
>
>Thanks
>Derek
>
>  
>
I think because in Cocoon you are using Xalan, you can do it this way

xmlns:math="http://exslt.org/math"

and then declaring 
<xsl:value-of  select="math:max(5,10)"/>

will work.

Alternative you can use the namespace
xmlns:math="xalan://java.lang.Math"

which will allow you to use the java functions.

The former is preferable as it is not dependent on
the stylesheet processor.

Norman

-- 
Norman Barker
Software Engineer
ComSine Ltd
Tel: +44 (0)1483 457121
Web: http://www.comsine.com
*Please Note:*
This text is confidential. If you are not the named addressee, it could be unlawful for you
to read, copy, distribute, disclose or use the information contained herewith. If you are
not the intended recipient please telephone +44(0)1483 457121.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message