XSLT调用JS  http://www.ibm.com/developerworks/cn/xml/tips/x-tipxsltjs/index.html
XSLT调用JAVA  http://unmi.cc/xslt-call-java-method

  1. package org.lvsenlin;
  2. import java.text.SimpleDateFormat;
  3. import java.util.Random;
  4. public class XsltFunctions {
  5. public static int re_int(int a){
  6. return a;
  7. }
  8. public static int re_random(int a){
  9. int r=new Random().nextInt(10000);
  10. return r;
  11. }
  12. public static String TimeStampDate(String timestampString){
  13. String date = new SimpleDateFormat("yyyy-MM-dd").format(Long.parseLong(timestampString));
  14. return date;
  15. }
  16. public static void main(String[] args) {
  17. String date = TimeStampDate("1322755200000");
  18. System.out.println(date);
  19. }
  20. }
package org.lvsenlin;

import java.text.SimpleDateFormat;
import java.util.Random; public class XsltFunctions {
public static int re_int(int a){
return a;
}
public static int re_random(int a){
int r=new Random().nextInt(10000);
return r;
}
public static String TimeStampDate(String timestampString){
String date = new SimpleDateFormat("yyyy-MM-dd").format(Long.parseLong(timestampString));
return date;
}
public static void main(String[] args) {
String date = TimeStampDate("1322755200000");
System.out.println(date);
}
}

<?xml version="1.0" encoding="UTF-8"?>

  1. <xsl:stylesheet version="1.0"
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:java="org.lvsenlin"
  4. exclude-result-prefixes="java">
  5. <xsl:template match="/">
  6. <msc type="form">
  7. <body>
  8. <xsl:value-of select='java:XsltFunctions.TimeStampDate("1322755200000")' />
  9. </body>
  10. </msc>
  11. </xsl:template>
  12. </xsl:stylesheet>
05-08 08:27