Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 9th, 2006, 05:23 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default Pass Value to XSLT variable

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


 
Old October 9th, 2006, 06:09 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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)
 
Old October 9th, 2006, 06:36 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
 
Old October 9th, 2006, 10:16 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

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







Similar Threads
Thread Thread Starter Forum Replies Last Post
assign XSLT variable to a wml variable arunagottimukkala XSLT 2 October 19th, 2007 05:15 AM
pass java variable to xsl variable kathy1016cats XSLT 1 June 14th, 2006 06:23 PM
pass the result of a query to a variable ... eusebio Pro VB Databases 6 March 30th, 2006 07:41 PM
pass variable kapi.goel C# 1 January 6th, 2006 05:54 AM
pass variable into function and retaining value mikeuk Beginning PHP 3 August 4th, 2004 06:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.