[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Passing parameters to xsl-stylesheet

Subject: RE: Passing parameters to xsl-stylesheet
From: "Andrew Welch" <andrew@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 31 Jan 2002 14:55:52 -0000
server.mappath javascript equivalent

The following ASP will get two params from the request and pass them into
your stylesheet.  For example, if you save this as addParams.asp then you
can supply params by calling it using:

<a href="addParams.asp?param1='hello'&param2='world'">...</a>

Then in your stylesheet you need to add some lines to receive the params,
like this:

<xsl:stylesheet xmlns:xsl.......
<xsl:param name="param1"/>
<xsl:param name="param2"/>

Then you can access the params in your stylesheet using $param1 and $param2.

So, <xsl:value-of select="$param1"/> would produce 'hello'.

You can change the names as long as you change them throughout, and have as
many as you like (although I guess there is some kind of limit...anyone?)

This should give you a start



(ps. this code is in VB... if anyone has the javascript equivalent that
would be cool)

=====the asp========

<% Response.Buffer=True %>
<% Dim xml
   Dim xsl
   Dim template
   Dim processor

   Set xml = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
   xml.async = false
   xml.load (Server.MapPath("/yourxml.xml"))

   Set xsl = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
   xsl.async = false
   xsl.load (Server.MapPath("/yourxsl.xsl"))

   Set template = Server.CreateObject("MSXML2.XSLTemplate")
   template.stylesheet = xsl
   set processor = template.createProcessor()

   processor.input = xml

   firstParam = Request.querystring("param1")

   if firstParam <> "" then
     processor.addParameter "param1", searchType
   end if

   secondParam = Request.querystring("param2")

   if secondParam <> "" then
     processor.addParameter "param2", searchVal
   end if


   Response.write (processor.output)

   Set xml = Nothing
   Set xsl = Nothing

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Ragulf
Sent: Thursday, January 31, 2002 2:04 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Passing parameters to xsl-stylesheet

Hello all,

What is the exact syntax of passing an argument (parameter) from an asp-page
to an xsl-stylesheet and what is the syntax for recieving the parameter in
the stylesheet?

I have a stylesheet that sorts an xml-file by various methods and want the
user to be able to choose which method to sort by.

Sorry, I know this is a real newbee question, and I have seen answers for it
before, but I can't find the answer in the archive and Michael Kay only
describe the passing in general terms that I can find (p. 284 in second

Raguld Pickaxe :)

Join the world?s largest e-mail service with MSN Hotmail.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.