This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Xalan Extensions


I have problems with my first extension for Xalan-Java 1

I wrote a simple java class that uses the SimpleDateFormat-class. It has
only one method that returns the formated date as a String.

My XSL-stylesheet should just call the method and return it in a
xsl:variable. I looked at the examples on the xalan home page, but I just
don't get it. Where do I create an instance of my class? How do I call a
method?

Thanks for any help!


**************************************************************
package util;

import java.util.*;
import java.text.*;

public class FinnishDate
{
  SimpleDateFormat finnishFormat = new
SimpleDateFormat("EEEE dd.MM.yyyy", new Locale("FI",
"FI"));

  public String getFinnishDate()
  {
    Date now = new Date();
    String finnishDate = finnishFormat.format(now);
    return finnishDate;
  }
}
*************************************
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0"

xmlns:java="http://xml.apache.org/xslt/java"; >

<xsl:variable name="fd"
select="java:util.FinnishDate.new()"/>

<xsl:template match="/">
 <html>
 <body>
 <p>
 <xsl:value-of select="date:getFinnishDate($fd)"/>
 </p>
 </body>
 </html>
</xsl:template>

</xsl:stylesheet>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]