2012-06-18 25 views
1

我想,當用戶選擇下拉我怎麼可以在下拉調用XSL的模板功能選擇

<xsl:element name="select"> 
<xsl:attribute name="id"> 
<xsl:value-of select="$l" /> 
</xsl:attribute> 

<xsl:attribute name="onchange"> 
<xsl:value-of select="TEMPLATE SHOULD BE CALLED HERE"/> 
</xsl:attribute> 

    <option value="1">Select</option> 
    <option value="2">Daily</option> 
    <option value="3">Weekly</option> 
    <option value="4">Monthly</option> 
    <option value="5">RunOnStartup</option> 

一個選項來調用XSL代碼模板功能

任何人都可以告訴我調用模板的語法。

回答

0

的XSL的語法:template元素可以在這裏找到:http://www.w3schools.com/xsl/el_template.asp

<xsl:template 
name="name" 
match="pattern" 
mode="mode" 
priority="number"> 

    <!-- Content:(<xsl:param>*,template) --> 

</xsl:template> 

name: name Optional. Specifies a name for the template. 
Note: If this attribute is omitted there must be a match attribute 

match pattern Optional. The match pattern for the template. 
Note: If this attribute is omitted there must be a name attribute 

mode: mode Optional. Specifies a mode for this template 
priority number Optional. A number which indicates the numeric priority of the template 
1

使用XSLT 1.0在瀏覽器中實現,XSLT樣式表生成HTML,以及所有事件處理必須可以在您作爲HTML一部分生成的Javascript代碼中完成。如果您想從該Javascript調用回XSLT,則必須使用轉換API來啓動新的轉換。

如果您使用Saxon-CE中實現的XSLT 2.0,則此更改。 Saxon-CE樣式表可以包含響應用戶事件的代碼。您不需要爲select元素生成「onchange」屬性。你只需要編寫一個模板規則是這樣的:

<xsl:template match="select" mode="ixsl:onchange"> 
    ... code goes here ... 
</xsl:template> 

當「的onchange」事件在HTML「選擇」元件上產生的模板將自動執行。

撒克遜-CE的更多信息(和實例)可以在這裏找到:

http://www.saxonica.com/ce/download.xml

相關問題