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 Adrian Herscu <ad...@gmail.com> on 2010/05/10 13:25:46 UTC
any known issues with Xalan 2.7.1 distributed with Sun's JRE 6?
Hi all,
I am trying to implement few XSL extension functions in Java and call
them from my XSL template.
I discovered that the ExpressionContext interface is not available and
so all the org.apache namespace (there is something like
com.sum.org.apache...internal.ExpressionContext but the compiler refuses
it).
Also discovered that no matter what the referenced FQCN is, the XSL
process always tries to invoke methods in the java.lang.String class.
For example
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:utils="com.acme.followed.by.this.garbage:@%#$%@#^#%#$"
extension-element-prefixes="utils">
Then this one works by calling the java.lang.String.length method !
<xsl:value-of select="utils:length('fff')" />
Regards,
Adrian.
Re: any known issues with Xalan 2.7.1 distributed with Sun's JRE
6?
Posted by Nathan Nadeau <nd...@gleim.com>.
Adrian Herscu wrote:
> Hi all,
>
> I am trying to implement few XSL extension functions in Java and call
> them from my XSL template.
>
> I discovered that the ExpressionContext interface is not available and
> so all the org.apache namespace (there is something like
> com.sum.org.apache...internal.ExpressionContext but the compiler
> refuses it).
>
> Also discovered that no matter what the referenced FQCN is, the XSL
> process always tries to invoke methods in the java.lang.String class.
>
> For example
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xalan="http://xml.apache.org/xalan"
> xmlns:utils="com.acme.followed.by.this.garbage:@%#$%@#^#%#$"
> extension-element-prefixes="utils">
Maybe you need to add a <xalan:component> section to your XSLT after the
namespace declarations:
<xalan:component prefix="utils">
<xalan:script lang="javaclass" src="yourClassName"/>
</xalan:component>
Or if your extension is implemented in Java it is recommended to use the
abbreviated syntax for extensions implemented in Java, which does not
require the <xalan:component> element. Setting the xmlns attribute alone
(which your example shows) is not enough since that value is not used to
actually locate your class, as far as I can tell.
See http://xml.apache.org/xalan-j/extensions.html and
http://xml.apache.org/xalan-j/extensions.html#java-namespace for more
details.
Also of course make sure your class is in the classpath.
>
>
> Then this one works by calling the java.lang.String.length method !
>
> <xsl:value-of select="utils:length('fff')" />
>
> Regards,
> Adrian.
>
--
Nathan Nadeau
ndn@gleim.com
Software Development
Gleim Publications, Inc.
http://www.gleim.com