Pass Query String Parameters to an XSL Transform Using the ASP.NET Xml Control
Page 1 of 2
Written by
Gregory Scot Collins
Friday, 19 May 2006, 5:19 PM
This article has been tested to work with the following products and versions. No guarantee of compatibility, with or without modification, is offered for products or versions other than those listed.
- ASP.NET 2.0 and 1.1 (Microsoft)
IN THIS ARTICLE:
It is not inherently obvious when using the asp:Xml control how to pass parameters to your XSL transform. It can be done, but will require a small amount of coding to set the parameter values and add the parameter list to the control. To demonstrate this we will create three sample files: an ASPX page, an XML file, and an XSL file.
Because we will be using Active Server Pages, you will need access to a .NET enabled Web server. We will assume that you have one installed locally and that you will be testing this on http://localhost. If you are working with a remote server, substitute in your server name and any required path.
Create the sample XML file
Let's start by creating a very simple XML file to act as the source of our transform. Since we are demonstrating parameter passing we don't need to get fancy, so we will only require an empty root node. Copy the contents of Listing 1 into a text editor, and then save the file as ParamTest.xml.
Create the sample XSL file
Copy the contents of Listing 2 into a text editor, and then save the file as ParamTest.xsl. Be sure to save it in the same folder as the ParamTest.xml file.
This XSL receives two parameters, PARAM1 and PARAM2, and then either displays their value, or informs you that the value (which includes blank values) is not available.


Stumble It!
Digg It!
del.icio.us




