Pass user input to XSL stylesheet

2019-08-09 20:21发布

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?

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.

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

1条回答
我命由我不由天
2楼-- · 2019-08-09 20:59

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

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

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

<xsl:value-of select="$key"/>
查看更多
登录 后发表回答