This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: dynamic pages with URL parameters
- To: xsl-list at mulberrytech dot com
- Subject: Re: dynamic pages with URL parameters
- From: Bill Humphries <bill at whump dot com>
- Date: Tue, 22 Aug 2000 23:45:13 -0700
- Reply-To: xsl-list at mulberrytech dot com
At 3:10 AM +0000 8/23/00, Ben C. wrote:
> How are you adding parameters to a URL to make dynamic pages? I know
>that you can feed parameters using the URL, but I have yet to figure out how
>to read and set them in a stylesheet. Is there any possible way I could get
>you to show me some extremly simple code for this?
I'm understanding this to mean that you want to pass a parameter into a style sheet from some calling script/shell/process and then use that parameter in a template that generates the URL?
So you have a stylesheet like:
<xsl:stylesheet ... >
<xsl:output method="html"/>
<xsl:parameter name="URLPARM"/>
<xsl:variable name="BASE">http://www.foo.com/dynamic.cgi?</xsl:variable>
<xsl:variable name="URL" select="concat($BASE,$URLPARM)"/>
<xsl:template match="/">
<html>
<head>
<title>example</title>
</head>
<body>
<a href="{$URL}">dynamic link</a>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
What platform are you writing this in? I've got working examples in PHP and ASP of how to pass parameters into a styleheet. You can then use the parameter to generate the URL.
PHP: http://www.whump.com/www/phpSablot.html
(Wrapper Class for PHP Sablotron XSLT Engine Extension)
See the notes on the setParameter method.
ASP: From a message on 8/3 which isn't in the searchable archives yet:
> Does MSXML ( dll v 5.*, IE 5 ) allow the use of Params or variables
syntax
> examples appreciated !!! ) ?
> I'm using the parser that came with Win 2k AS with no updates.
You'll need to make sure you have the May or later release of the parser.
>From reading the documentation in the SDK and Michael Kay's book (you
know he will be known as St. Michael soon :> )
You can't use the transformNode method of the DOM, instead, you need
to create a XSLTemplate object, get an XSLTProcessor object from it,
then use the addParameter method.
<%@LANGUAGE="VBScript"%>
<%
Dim xsldoc
Dim myTemplate
Dim myProc
Dim xmldoc
'It has to be Free-Threaded, the idea is to make the widget available
'to an app and have multple users bang on it.
Set xsldoc = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
xsldoc.async = false
xsldoc.load Server.MapPath("tranform.xsl")
'This is the critical widget, a compliled XSL template
Set myTemplate = Server.CreateObject("Msxml2.XSLTemplate.3.0")
myTemplate.stylesheet = xsldoc
Set xmldoc = Server.CreateObject("Msxml2.DOMDocument.3.0")
xmldoc.async = false
xmldoc.load Server.MapPath("input.xml")
Set myProc = myTemplate.createProcessor()
myProc.input = xmldoc
'Now set the parameter
myProc.addParameter(URLPARM,"somestring")
myProc.output = Response
myProc.transform()
%>
Bill Humphries <bill@whump.com>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list