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>

谁能告诉我调用模板的语法。

4

2 回答 2

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>

当 HTML 中的“select”元素发生“onchange”事件时,模板将自动执行。

Saxon-CE 的更多信息(和示例)可以在这里找到:

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

于 2012-06-18T07:42:55.463 回答
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
于 2012-06-18T05:07:27.020 回答