[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: FW: XSL calling Java problem - urgent

Subject: RE: FW: XSL calling Java problem - urgent
From: "Ha Wai Hoe" <whha@xxxxxxxxxx>
Date: Fri, 15 Oct 2004 13:58:44 +0800
call java from xsl
Hi,
Well it's done! It is due to the classpath problem.
I am very sure with the answer given will definitely helps a lot of ppl
who are trying to call Java program from xsl.


:)

-----Original Message-----
From: Manpreet Singh [mailto:singhm@xxxxxxxxxxx]
Sent: Friday, October 15, 2004 1:05 PM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: RE:  FW: XSL calling Java problem - urgent
Importance: High

Hi,

  Paste the following as indicated:

<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:java="sample.HelloDate"
exclude-result-prefixes="java">

<xsl:template match="/">
<xsl:variable name="date" select="'2004-12-20 01:01:01'"/>
<xsl:variable name="format" select="'dd/mm/yyyy'"/>

<p>Date: <xsl:value-of select="java:getDate($date, $format)"/></p>
</xsl:template>
</xsl:stylesheet>

Make an xsl file with above code.

package sample;
import java.text.SimpleDateFormat;
import java.sql.Timestamp;

public class HelloDate
{
public static String getDate(String inputDate, String dateFormat)
{
String outPutDate = "";
System.out.println("dateFormat " + dateFormat);

if ( inputDate != null && inputDate != "")
{
SimpleDateFormat patternDateTimeFormat = new
SimpleDateFormat ( dateFormat );
outPutDate = patternDateTimeFormat.format
(Timestamp.valueOf ( inputDate ) );
System.out.println(outPutDate);
}
else
{
outPutDate = "";
}
return outPutDate;
}
}

Make a java file with the above code and place it in a directory by the
name
sample.

Place the xsl, a dummy xml with empty root tag and the directory sample
containing the class file for the above java file in same directory.
>From command prompt fire the following command:

C:\(Path till directory where the above described file and page are
kept)>
java org.apache.xalan.xslt.Process -in XML_FILE -xsl XSL_FILE -out
OUTPUT_XML(just give a name with xml extension).

PS: Give the path of directory containing JDK in the CLASSPATH
environment
variable if the above does not work.

Regards
Manpreet

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.