zoukankan      html  css  js  c++  java
  • XSLT 调用java

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

    Java代码  
    1. package org.lvsenlin;   
    2.   
    3. import java.text.SimpleDateFormat;   
    4. import java.util.Random;   
    5.     
    6. public class XsltFunctions {   
    7.     public static int re_int(int a){   
    8.         return a;   
    9.     }   
    10.     public static int re_random(int a){   
    11.         int r=new Random().nextInt(10000);   
    12.         return r;   
    13.     }   
    14.     public static String TimeStampDate(String timestampString){       
    15.         String date = new SimpleDateFormat("yyyy-MM-dd").format(Long.parseLong(timestampString));   
    16.         return date;   
    17.     }      
    18.     public static void main(String[] args) {   
    19.         String date = TimeStampDate("1322755200000");   
    20.         System.out.println(date);   
    21.     }   
    22. }  
    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代码  
    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.   
    6.     <xsl:template match="/">  
    7.         <msc type="form">  
    8.             <body>  
    9.                 <xsl:value-of select='java:XsltFunctions.TimeStampDate("1322755200000")' />  
    10.             </body>  
    11.         </msc>  
    12.     </xsl:template>  
    13. </xsl:stylesheet>  
  • 相关阅读:
    C#实现注册码
    多表链接 Left join
    Repeater 一行显示两列数据
    Repeater一行显示数据库中多行表记录
    HP QC(Quality Center)在Windows 7 IE8 IE9下不能工作解决方案
    Android应用换肤总结
    Lua 第一个应用程序 Hello World
    JNI 技术与 Android 应用
    NSAutoreleasePool' is unavailable: not avail
    1-2基础控件
  • 原文地址:https://www.cnblogs.com/qingzhou/p/4205702.html
Copyright © 2011-2022 走看看