将用户输入传递给 XSL 样式表 [英] Pass user input to XSL stylesheet

查看:32
本文介绍了将用户输入传递给 XSL 样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 XSL 2.0 样式表扩展用 java 和 javascript 编写的 web 服务.样式表基于此(XSLT 2.0: Transform notation以纯文本格式转换为 svg) XSL 表并将纯文本转换为 svg.目前,可以从变量或文件转换文本,但用户应该可以将他的输入输入到 web 服务中,并将此输入传递到 xsl 表,然后将被转换.这怎么可能?

I want to expand a webservice written in java and javascript with a XSL 2.0 stylesheet. The stylesheet is based on this(XSLT 2.0: Transform notation in plain text to svg) XSL sheet and transforms plain text into svg. At the moment it is possible to transform the text from a variable or a file, but it should be possible that the user does his input into the webservice and this input is passed to the xsl sheet and then will be transformed. How would this be possible?

为了让您更好地了解所需的工作流程,如下所示:我已经有了一个按钮.当用户单击按钮时,会出现一个带有文本区域的窗口.用户输入他的纯文本,点击按钮后,这个数据应该从 textarea 传递到 xsl 表.然后应该执行转换并返回结果.

To give you a better understanding the desired workflow is something like this: I already have a button. When the user clicks the button a window with a textarea appears. The user inputs his plain text and after a click on a button this data should be passed to the xsl sheet from the textarea. Then the transformation should be performed and the result should be returned.

如何将用户输入传递到 XSL 表?任何帮助,将不胜感激.谢谢!

How is it possible to pass user input to the XSL sheet? Any help would be appreciated. Thanks!

推荐答案

使用transformer.setParameter("key", "value");

Use transformer.setParameter("key", "value");

并在样式表中使用<xsl:param name="key"/> 在样式表的开头.

and within the stylesheet use <xsl:param name="key" /> at the beginning of your stylesheet.

然后您可以像引用任何其他 xsl 变量一样引用它:例如

Then you refer to it like to any other xsl variable: e.g.

<xsl:value-of select="$key"/>

这篇关于将用户输入传递给 XSL 样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆