Subject: Re: [xsl] URL variables From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 16 Aug 2001 17:33:10 +0100 |
Hi John, > It was my understanding that in order to get a variable from the URL > you need to do a <xsl:param name="id" select="."/> before your first > template call and then inside a template to access it (i.e. print > the value) you would need to do a <xsl:value-of select="$id"/>. Can > anyone tell me if I am one the right track, or am I way off the > mark. It depends what kind of framework you're working in. If you're using Cocoon, then it's true that if you have a name=value pair in the URL then you can get hold of the value by declaring and using a parameter in your stylesheet. However, that's not necessarily true if you're transforming in some other way, in particular not if you're using client-side transformations with MSXML. In those cases you have to use a server-side script to manage the transformation by passing in the relevant parameter values. Given that you're using Cocoon, you still need to make sure that the name of the parameter that you declare is the same as the name of the input field that you use to set the parameter - this wasn't the case in the code that you posted. So if you use the name 'id1' (as you did) in the input field, you have to declare the parameter as 'id1' in the stylesheet, e.g.: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:param name="id1" /> <xsl:template> <html> <body> THE ID ENTERED IS : <xsl:value-of select="$id1"/> </body> </html> </xsl:template> </xsl:stylesheet> BTW, there's no need for the xsl:param element to go at the top of the stylesheet (although no reason why it shouldn't either). Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] URL variables, John Bougie | Thread | Re: [xsl] URL variables, Carlos |
RE: [xsl] URL variables, Crowers, Steve | Date | Re: [xsl] xsl:when conditions, Jeni Tennison |
Month |