2009-12-11 93 views
2

我想將我從XML獲取的值employee_name傳遞給XSL中的用戶定義函數。請參閱下面的代碼:如何將值傳遞給XSLT中的用戶定義函數

<xsl:for-each select="employees/employee"> 
    <xsl:value-of select="employee_name"/> 
    <xsl:value-of select=" 
    my:compareCI(
     '--how to pass employee_name Value--', 
     '--how to pass employee_name Value--' 
    ) 
    " /> 
</xsl:for-each> 

請任何幫助我,因爲我是新來的XSL。

+0

我假設你的意思是XSL或XSLT。標題拼錯 – 2009-12-11 12:40:54

+0

請注意,這僅在XSLT2.0中可用,並且某些系統仍然只支持XSLT1.0 – 2009-12-11 12:41:27

回答

5
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:ns1="http://www.example.com"> 


    <xsl:function name="ns1:functionName"> 
     <xsl:param name="employee_name"/> 
     <xsl:value-of select="$employee_name"/> 
    </xsl:function> 

    <xsl:template match="/"> 
     <xsl:value-of select="ns1:functionName('John Doe')"/> 
    </xsl:template> 
</xsl:stylesheet> 
相關問題