[xsl] RE: How to call an external Java function

Subject: [xsl] RE: How to call an external Java function
From: Peter Kester <Peter.Kester@xxxxxxxxxxx>
Date: Fri, 9 Jan 2009 09:31:38 +0100
Hi Steve,

Is your class in a certain package or is it in the default package?
Eg. If your class is in package com.medtronic.utils then you have to add the
package name to the namespace:
I use the same sort of calls and in my env it works like a charm (inside
Oxygen If you set the extensions correct and outside Oxygen if you set the
classpath right)
If I remove part of the package name I receive the same kind of error



Ing. P.A. Kester
Senior Consultant

Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
KvK 27164984
De informatie - verzonden in of met dit emailbericht - is afkomstig van
Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit
bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit
bericht kunnen geen rechten worden ontleend.

Van: Ylvisaker, Steve [mailto:steve.j.ylvisaker@xxxxxxxxxxxxx]
Verzonden: donderdag 8 januari 2009 20:42
Aan: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Onderwerp: [xsl] How to call an external Java function

I have a working Java function that uses FontMetrics to determine the length
in points of a given character stream. I am able to call the function from the
windows command line and it runs just as I expect. Now I  want to call that
same function from my XSL stylesheet and I can't seem to get the correct

I have set my classpath environment variable to include the path:

I have placed FontWidth.jar in folder c:\maps-jars

FontWidth is the Java class.

And I have run the following simple transformation with Saxon8:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet  version="2.0"

    <xsl:template match="/">

        <xsl:variable name="testJava">
            <xsl:value-of select="med:labelStringWidth('Helvetica World', 12,
'This is test text')"/>

        <xsl:message>result:<xsl:value-of select="$testJava"/></xsl:message>



labelStringWidth is a method belonging to class FontWidth.

I have run this under <oxygen/> and stand alone from the command line with
Saxon8 and in both situations I receive the following error message:

Description: XPath syntax error at char 64 on line 11 in {...rld', 12, 'This
is test tex...}: Cannot find a matching 3-argument function named

Any help I can get on this would be very much appreciated.


Information transmitted by this email is proprietary to Medtronic and is
intended for use only by the individual or entity to which it is addressed,
and may contain information that is private, privileged, confidential or
exempt from disclosure under applicable law. If you are not the intended
recipient or it appears that this mail has been forwarded to you without
proper authority, you are notified that any use or dissemination of this
information in any manner is strictly prohibited. In such cases, please delete
this mail from your records.

To view this notice in other languages you can either select the following
link or manually copy and paste the link into the address bar of a web
browser: http://emaildisclaimer.medtronic.com

Current Thread