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

Passing parameters through javascript: what does or d

Subject: Passing parameters through javascript: what does or doesn't work
From: Davide Girlando <dado2_714@xxxxxxxx>
Date: Tue, 25 Apr 2006 01:31:11 +0200 (CEST)
javascript params
Hello everyone, I'm an XSLT novice and I tried out this technology to make a job for my apprentice
period in a firm, that is also my Bachelor Thesis. I'm using Javascript to pass parameters, with
some code I adapted from some research which uses ActiveX; I'm not so satisfied with this, but I'm
making it easy to eventually switch to PHP when everything will be transfered on a server.
Coming to the issue, I've written this code as a part of a template: it should provide links to a
dynamic item paging control.

>> fl.xsl

<xsl:param name="viewmethod" select="'js'"/>
<xsl:param name="itemsperpage" select="'50'"/>
<xsl:param name="page" select="'1'"/>
	<xsl:for-each select="/rdf:RDF/nm:flItem[(position() - 1) mod $itemsperpage = 0]">
		<xsl:call-template name="link">
			<xsl:with-param name="text">
				<xsl:value-of select="position()"/>
			<xsl:with-param name="view">
			<xsl:with-param name="param">
product=<xsl:value-of select="/rdf:RDF/nm:productName[1]"/>&amp;itemsperpage=<xsl:value-of
select="$itemsperpage"/>&amp;page=<xsl:value-of select="position()"/>
<xsl:template name="link">
	<xsl:param name="text"/>
	<xsl:param name="view"/>
	<xsl:param name="param"/>
		<xsl:when test="$viewmethod = 'js'">
				<xsl:attribute name="href">
javascript:match('<xsl:value-of select="$view"/>','<xsl:value-of select="$param"/>');
				<xsl:value-of select="$text"/>

This is the javascript file that is automatically recalled by all the 
pages generated by the
template (with a <script> tag, omitted here):

>> nm.js

function match(view, param) {
	var params = param.split("&");
	var product;
	for (var i=0; i<params.length; i++) {
		if (params[i].split("=")[0]=="product") {
	var xslt = new ActiveXObject("Msxml2.XSLTemplate");
	var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
	var xslProc;
	xslDoc.async = false;
	xslDoc.resolveExternals = false;
    	xslt.stylesheet = xslDoc;
    	var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
    	xmlDoc.async = false;
    	xmlDoc.resolveExternals = false;
    	xslProc = xslt.createProcessor();
    	xslProc.input = xmlDoc;
	for (var i=0; i<params.length; i++) {

Looks like the generated page ignores the parameters. I've verified that the function reads
correctly parameters names and values from the "param" string; I've also verified that typing
manually something like


unexpectedly works. This looks rally weird to me! Anybody has any idea what happens inside the IE
javascript interpreter?

Davide Girlando


Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 

Current Thread


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.
First Name
Last Name
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.