XSLT调用JS http://www.ibm.com/developerworks/cn/xml/tips/x-tipxsltjs/index.html
XSLT调用JAVA http://unmi.cc/xslt-call-java-method
- 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);
- }
- }
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"?>
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:java="org.lvsenlin"
- exclude-result-prefixes="java">
- <xsl:template match="/">
- <msc type="form">
- <body>
- <xsl:value-of select='java:XsltFunctions.TimeStampDate("1322755200000")' />
- </body>
- </msc>
- </xsl:template>
- </xsl:stylesheet>