[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] XSL reading URL properties


Subject: RE: [xsl] XSL reading URL properties
From: John Pallister <jpallister@xxxxxxxxxxxx>
Date: Fri, 13 Dec 2002 10:22:04 -0500

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
Keywords