Subject: Pass Value to XSLT variable
Posted By: bonekrusher Post Date: 10/9/2006 5:23:56 AM
Hi,

I am trying to learn how to pass a value from either HTML, ASP or Javascript to an XSLT variable. I done a lot of searching, and have no luck.

I would like to pass the value to the following line in xslt:

<xsl:variable name="getvalue">PASSED VALUE HERE</xsl:variable>

Does anyone know how its done? I can use any of the following formats: HTML, ASP or Javascript

Thanks for the help.

Bones


Reply By: joefawcett Reply Date: 10/9/2006 6:09:01 AM
Normally you define "variables" that you want to modify externally as xsl:param elements that are direct children of the xsl:stylesheet. It is possible to modify xsl:variable but it's a bit messy. What XSLT processor are you using and what platform and host, e.g. .NET processor, Windows and ASP.NET or Saxon, Windows and JSP?

--

Joe (Microsoft MVP - XML)
Reply By: mhkay Reply Date: 10/9/2006 6:36:36 AM
You want to define a parameter, not a variable: <xsl:param name="x"/> as a child of xsl:stylesheet.

Then when you invoke the transformation (e.g. from Javascript) you'll find the API offers a method such as setParameter() or addParameter() to supply an external value for the parameter.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply By: bonekrusher Reply Date: 10/9/2006 10:16:26 AM
Thanks guys... I plan on using ASP.NET to process. I will have a web page with an input box and submit button. The inputbox value will be passed to the xslt <xsl:param name="x"/> (thanks Michael) on the post back from the server.

I will research "setParameter() or addParameter() "...This should keep me busy. Thanks for the help.

Bones



Go to topic 50773

Return to index page 153
Return to index page 152
Return to index page 151
Return to index page 150
Return to index page 149
Return to index page 148
Return to index page 147
Return to index page 146
Return to index page 145
Return to index page 144