XSLT Call JS http://www.ibm.com/developerworks/cn/xml/tips/x-tipxsltjs/index.html
XSLT calls Java Http://unmi.cc/xslt-call-java-method
Java code
- 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"?>
XML code
- <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>
XSLT calls Java