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

RE: XSL reading URL properties

Subject: RE: XSL reading URL properties
From: John Pallister <jpallister@xxxxxxxxxxxx>
Date: Fri, 13 Dec 2002 10:22:04 -0500
reading url parameters
I also had a similar situation at work, to develop a client-side
solution with no ASP, no server, no database, no help, etc, 
but I did get to use client-side JavaScript to achieve the end result.

I agree with Steve Gold that you will need some sort of nonXSL interaction. 

I passed my form parameters from page1.htm to page2.htm using method="LINK" 
and then in page2.htm, using XSLT processing with client-side script 
the parameter can be processed with your XML and XSLT file that you specify.

Your XSLT file would then need to use <xsl:param name="param1"/>
to process the parameter passed.  

My simple example below:

page1.htm:
<html>
<head>
<title></title>
</head>
<body>
 <form method="link" action="page2.htm" id="form1" name="form1">
  <div><span class="caption">Enter Name</span><br><br>            
   <input class="input" type="number" name="param1" id="param1" size="42"
maxlength="42">         
   <input type="submit" value="Go" class="input" id="submit" name="submit1">
  </div>
 </form>
</body>
</html>

page2.htm:
<html>
<head>
<title>title</title>
</head>
<SCRIPT LANGUAGE="javascript">
function delineate(str)
{
theleft = str.indexOf("=") + 1;
theright = str.lastIndexOf("&");
if (theright<1)
	{return(str.substring(theleft));}
else
	{return(str.substring(theleft, theright));}
}

function load()
  {    
     var locate = window.location
     document.form1.param1.value = locate
     var text = document.form1.param1.value 
     //document.write("Parameter1 is " +delineate(text));
     xml  = new ActiveXObject("Msxml2.DOMDocument.4.0");
     xml.async = false;
     xml.load("duck.xml");
     xsl = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
     xsl.async = false;
     xsl.load("whatisit.xsl");
     template = new ActiveXObject("Msxml2.XSLTemplate.4.0");
     template.stylesheet = xsl;
     processor = template.createProcessor();
     processor.input = xml;
     processor.addParameter("param1", delineate(text));
     processor.transform();
     document.write(processor.output);
  }
</SCRIPT>
<body onload="load()">
<form id="form1" name="form1">
<INPUT TYPE="hidden" NAME="param1"/>
</form>
</body>
</html>

whatisit.xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="param1" />
<xsl:template match="/">
<html>
<head>
</head>
 <body>
<xsl:apply-templates mode="hi">
<xsl:with-param name="param1" />
</xsl:apply-templates>
  </body>
 </html>
</xsl:template>
<xsl:template mode="hi" match="joke">
  <table>
   <tr><td>Hello <xsl:value-of select="$param1" />! <xsl:value-of select="."
/></td></tr>
  </table>
</xsl:template>
</xsl:stylesheet>

duck.xml:
<?xml version="1.0"?>
<jokes>
<joke type="oneline">
A duck walks into a bar, goes to the bartender, and says, "Give me a beer
and put it on my bill."
</joke>
</jokes>


Hope this helps,
John Pallister
jpallister@xxxxxxxxxxxx

 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-2013 All Rights Reserved.