xsl-list
[Top] [All Lists]

RE: FW: XSL calling Java problem - urgent

2004-10-14 03:43:07
Hi,

This is the source:

XSL Source
<?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"/>
<!--2004-12-20 01:01:01</xsl:variable--> 
<xsl:variable name="format" select="dd/mm/yyyy"/>
<!--dd/mm/yyyy</xsl:variable--> 


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




--------------------------------

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;
}
}



Regards,

-----Original Message-----
From: Manpreet Singh [mailto:singhm(_at_)quark(_dot_)co(_dot_)in] 
Sent: Thursday, October 14, 2004 5:57 PM
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: RE: [xsl] FW: XSL calling Java problem - urgent
Importance: High

Hi,
  Can you send in your updated XSL.
Regards
Manpreet

-----Original Message-----
From: Ha Wai Hoe [mailto:whha(_at_)ebworx(_dot_)com]
Sent: Thursday, October 14, 2004 3:28 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] FW: XSL calling Java problem - urgent


Hi again, 
I have done according to what you'd said, there is still error like this:

(Location of error unknown)XSLT Error
(javax.xml.transform.TransformerException): java.lang.NoSuchMethodException:
For extension function, could not find method
java.lang.Double.getDate([ExpressionContext,] #NODESET).


This one I have really no idea what is it all about.
Could you please help again. 




-----Original Message-----
From: Manpreet Singh [mailto:singhm(_at_)quark(_dot_)co(_dot_)in] 
Sent: Thursday, October 14, 2004 3:07 PM
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: RE: [xsl] FW: XSL calling Java problem - urgent
Importance: High

Hi,

 xmlns:java="http://xml.apache.org/xalan/java";
Try replacing the above with 
 xmlns:java="(location of your package from root)"

Include the package in your classpath and run.

Regards
Manpreet

-----Original Message-----
From: Ha Wai Hoe [mailto:whha(_at_)ebworx(_dot_)com]
Sent: Thursday, October 14, 2004 12:17 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] FW: XSL calling Java problem - urgent


Hi, 

It is still the same error. 
I think xsl could not locate the java class file.
Is there any step that I missed? 

Thank you

-----Original Message-----
From: Manpreet Singh [mailto:singhm(_at_)quark(_dot_)co(_dot_)in] 
Sent: Thursday, October 14, 2004 2:20 PM
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: RE: [xsl] FW: XSL calling Java problem - urgent
Importance: High

hi,

See if the following helps in xsl.

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

regards
Manpreet

-----Original Message-----
From: Ha Wai Hoe [mailto:whha(_at_)ebworx(_dot_)com]
Sent: Thursday, October 14, 2004 11:54 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] FW: XSL calling Java problem - urgent


Hi All,

I have some problem in calling JAVA program from XSLT.
Can you anyone please help cos it's urgent.


Thank you .


Regards



Error Encountered
(Location of error unknown)XSLT Error
(javax.xml.transform.TransformerException):
javax.xml.transform.TransformerException: java.lang.ClassNotFoundException:
sample/HelloDate



JAVA file
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;
}
}



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

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

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







--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--