1

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!

Community
  • 1
  • 1
Randy Random
  • 69
  • 2
  • 8
  • How do you call the transformation process? – Mathias Müller Feb 10 '16 at 13:59
  • Sry for the late reply, I tried to solve my problem but could not find a solution. I realized I don't know how to call the transformation, because my stylesheet takes plain text and transforms it to svg. So I want to pass the parameter with the text to the xsl and transform it, but i don't know how to run it because my sheet does't take a xml input so I can't use transformer.transform for instance. Do you know how this is possible? Thx! – Randy Random Feb 13 '16 at 15:05
  • Then just use any dummy XML document as the XML input, you do not have to make use of it in any way. Just process what you handed to the processor in a `xsl:param` element. – Mathias Müller Feb 13 '16 at 22:45

1 Answers1

1

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"/>
robert
  • 978
  • 7
  • 17
  • Sry for the late reply, I tried to solve my problem but I couln't find a solution. I want to perform the transformation and my xsl transforms plain text so svg. So I want to pass the text with setParameter and perform the transformation with this input, but how can I perform the transformation form java. My sheet doesn't take a xml input, it only takes the plain text and transforms it so I can't use transformer.transform because it needs a xml input. Do you know how this is possible? Thx! – Randy Random Feb 13 '16 at 15:01