Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 27th, 2009, 10:17 AM
Authorized User
 
Join Date: Oct 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy How to invoke Java calss with XSLT

Hi,

I am using XSLT1.0 and Saxon with Arbortext, I want to Print "HELLO" word with the help of java file. [This is a test java program with xslt 1.0 for me, afterwords in that program i will put another code for different purpose]

************************************
XML is a sbelow,
************************************
<?xml version="1.0" encoding="UTF-8"?>
<foo>
<p></p>
</foo>

************************************
XSLT as below
************************************
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="foo">
<xsl:apply-templates />
</xsl:template>

<xsl:template match="p">
<xsl:variable name="date"><xsl:call-template name="currentTime" /></xsl:variable>
Date: <xsl:value-of select="$date" />
</xsl:template>

<xsl:template name="currentTime"
xmlns:date="java:java.util.Date">
<xsl:value-of select="date:new()"/>
</xsl:template>

</xsl:stylesheet>

In above "currentTime" executes very well.

Now if I want to put my namespace and print "Hello", what are the things i have to consider.

I am having
1] Hello.java
2] Hello.class
3] Hello.jar
4] package created as com.mypro.hello

I am putting all the files [xml/xsl/class etc] in one directory only.

But my SUN / SDK / JDK folder location is different.

I have searched on net for the same but not succeed.
Every time i got same error as "Cannot find a matching 0-argument function named {java.....}say()"

Please suggest.

Thanks in advance.
 
Old November 27th, 2009, 10:25 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The class containing the method that you want to call needs to be on the Java classpath.

(It doesn't need to be in the same directory as Saxon or the stylesheet, and there's no particular advantage in putting it there.)

I'm not sure what Saxon release you are using. Later releases have a command line option -TJ that gives you extra diagnostics about loading extension functions.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using XSLT and JAVA trinkets XSLT 4 April 4th, 2007 02:13 PM
XSLT 2.0 Transformer for Java albinjoseph XSLT 1 March 2nd, 2007 04:05 AM
XSLT and JAVA bonekrusher XSLT 3 August 9th, 2006 07:38 PM
XSLT with Java Hind XSLT 1 May 24th, 2006 04:18 AM
binding java from xslt mountainbiker XSLT 2 February 19th, 2004 11:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.