[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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


Subject: [xsl] RE: How to call an external Java function
From: "Ylvisaker, Steve" <steve.j.ylvisaker@xxxxxxxxxxxxx>
Date: Fri, 9 Jan 2009 08:35:02 -0600

Peter - we have tried this both ways, default and certain package. The results
using the xmlns as you have described remains the same. It has become evident
that Saxon does not pay attention to the global classpath setting and as a
result cannot find my .jar. As a work around we have placed the .jar in
..\lib\ext and then are able to find it just fine. My target environment,
ultimately, is Unix where I anticipate things will work much better.

Does this sound correct to you?

Steve

-----Original Message-----
From: Peter Kester [mailto:Peter.Kester@xxxxxxxxxxx]
Sent: Friday, January 09, 2009 2:32 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] RE: How to call an external Java function

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:
Xmlns:med="java:com.medtronic.utils.FontWidth"
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 message.

Regards,

Peter




Ing. P.A. Kester
Senior Consultant


http://www.daidalos.nl/
Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
http://www.daidalos.nl/
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
incantation.

I have set my classpath environment variable to include the path:
c:\maps-jars\FontWidth.jar

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"
    xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:med="java:FontWidth"
    extension-element-prefixes="med">

    <xsl:template match="/">

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

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

    </xsl:template>

</xsl:stylesheet>

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
{java:FontWidth}labelStringWidth()

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


[CONFIDENTIALITY AND PRIVACY NOTICE]

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
Keywords