Subject: Re: dynamic pages with URL parameters From: Aaron Miller <amiller@xxxxxxxxx> Date: Wed, 23 Aug 2000 11:15:29 -0700 |
Ben, Yes. The parameters passed on the url to a servlet are automatically inserted into the XML tree result. So they can then be accessed via the XSL. This has the same effect as creating a CGI query object in Perl or passing params on the URL to a PHP. The code below shows storing a value from the URL, which is represented in the "param" node of the XML, into an XSL variable which is then used later in the page: <xsl:variable name="max_per_page">5</xsl:variable> <xsl:variable name="start"><xsl:value-of select="/root/params/start"/></xsl:variable> <xsl:variable name="end"><xsl:value-of select="number($start) + number($max_per_page) - 1"/></xsl:variable> Then, this code shows two ways to grab values from the URL and put them into another URL - one using javascript (the uncommented) and one using an attribute tag to modify a src attribute (commented code): <?xml version='1.0'?> <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match="/"> <HTML> <HEAD><TITLE>Zatso Enhancements</TITLE> <script language="Javascript" src="js/zlib.js"></script> </HEAD> <xsl:call-template name="EnhancementFrameset"> <xsl:with-param name="storyID"> <xsl:value-of select="/root/session/url/storyID" /> </xsl:with-param> <xsl:with-param name="enhancementIndex"> <xsl:value-of select="/root/session/url/enhancementIndex" /> </xsl:with-param> </xsl:call-template> </HTML> </xsl:template> <xsl:template name="EnhancementFrameset"> <xsl:param name="storyID">0</xsl:param> <xsl:param name="enhancementIndex">0</xsl:param> <SCRIPT language="Javascript"> <![CDATA[var menuURL = "cs.EnhancementNav.dyn?storyID=]]><xsl:value-of select="/root/session/url/storyID" /><![CDATA[&enhancementIndex=]]><xsl:value-of select="/root/session/url/enhancementIndex" /><![CDATA[";]]> <![CDATA[var displayURL = "cs.EnhancementDisplay.dyn?storyID=]]><xsl:value-of select="/root/session/url/storyID" /><![CDATA[&enhancementIndex=]]><xsl:value-of select="/root/session/url/enhancementIndex" /><![CDATA[";]]> function loadFrames() { document.frames[0].location = unescape(menuURL); alert('going to load: '+ menuURL) document.frames[1].location = unescape(displayURL); } </SCRIPT> <FRAMESET rows="100px, *" border="0" onload="javascript:loadFrames()"> <FRAME name="EnhancementMenu" scrolling="no" marginwidth="0" marginheight="0" frameborder="no"> <!--xsl:attribute name="src">cs.EnhancementNav.dyn?storyID=<xsl:value-of select="/root/session/url/storyID" />&enhancementIndex=<xsl:value-of select="/root/session/url/enhancementIndex" /></xsl:attribute--> </FRAME> <FRAME name="EnhancementDisplay" scrolling="no" marginwidth="0" marginheight="0" frameborder="no"> <!--xsl:attribute name="src">cs.EnhancementDisplay.dyn?storyID=<xsl:value-of select="/root/session/url/storyID" />&enhancementIndex=<xsl:value-of select="/root/session/url/enhancementIndex" /></xsl:attribute--> </FRAME> </FRAMESET> </xsl:template> </xsl:stylesheet> > From: "Ben C." <tatsu2000@xxxxxxxxxxx> > Reply-To: xsl-list@xxxxxxxxxxxxxxxx > Date: Wed, 23 Aug 2000 03:10:56 GMT > To: xsl-list@xxxxxxxxxxxxxxxx > Subject: dynamic pages with URL parameters > > AAron, > 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? > > Thanks, > Ben > ________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com > > > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: dynamic pages with URL paramete, Bill Humphries | Thread | name() and attribute() ?, Lee Goddard |
Re: Please be specific in your subj, XSL-List Owner | Date | SUMMARY: Selecting unique value of , Paul Terray |
Month |