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

Re: dynamic pages with URL parameters

Subject: Re: dynamic pages with URL parameters
From: Aaron Miller <amiller@xxxxxxxxx>
Date: Wed, 23 Aug 2000 11:15:29 -0700
javascript url parameters
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" />&amp;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" />&amp;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

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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-2011 All Rights Reserved.