选择下拉列表时如何调用XSL的模板函数

how can i call a template function of xsl when drop down is selected

本文关键字:XSL 函数 调用 下拉列表 何调用 选择      更新时间:2023-09-26

当用户在下拉列表中选择一个选项时,我正在尝试在 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>

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

在浏览器中实现的 XSLT 1.0 中,XSLT 样式表生成 HTML,并且所有事件处理都必须在作为 HTML 的一部分生成的 Javascript 代码中完成。如果要从该 Javascript 回调到 XSLT,则必须使用转换 API 来启动新的转换。

如果您使用在 Saxon-CE 中实现的 XSLT 2.0,则此情况会发生变化。Saxon-CE 样式表可以包含响应用户事件的代码。您不需要为选择元素生成"onchange"属性。你只需要编写一个这样的模板规则:

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

当 HTML 中的"选择"元素上发生"onchange"事件时,模板将自动执行。

有关撒克逊-CE的更多信息(和示例),请点击此处:

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

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