[xsl] Problem passing parameter ASP -> XSL

Subject: [xsl] Problem passing parameter ASP -> XSL
From: "Garry Searle" <garry@xxxxxxxxxxxxxxxxxx>
Date: Tue, 25 Jul 2006 21:42:28 +0930
Hi

I'm putting together my first xml-xsl together and have just one problem. I
cant seem to get a parameter to work. I'm wanting to pass the parameter from
an .ASP page.

I am calling this page with:  showStage.asp?paramVal1=test&paramVal2=12
and the full ASP and XSL documents are below.

I set a default paramter which displays, but the passed parameter is blank.

I'd appreciate any feedback.

Thanks
Garry



SHOWSTAGE.ASP
=============

<%@ LANGUAGE="VBSCRIPT" %>
<% option explicit %>
<% Response.Buffer=True %>
<%
  Dim objXML, objXSL, xslTemplate, xslProc, paramVal1, paramVal2

  set objXML = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
  objXML.async = false
  objXML.load(Server.MapPath("StageInfo.xml"))

  set objXSL = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
  objXSL.async = false
  objXSL.load(Server.MapPath("Stage.xsl"))

  set xslTemplate = Server.CreateObject("MSXML2.XSLTemplate")
  xslTemplate.stylesheet = objXSL
  set xslProc = xslTemplate.createProcessor()

  paramVal1 = Request.querystring("paramVal1")
  if paramVal1 <> "" then
    xslProc.addParameter "paramVal1", paramVal1
  end if

  paramVal2 = Request.querystring("paramVal2")
  if paramVal2 <> "" then
    xslProc.addParameter "paramVal2", paramVal2
  end if

  xslProc.input = objXML
  xslProc.transform()
  Response.Write(xslProc.output)
%>

STAGE.XSL
=========

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">
<xsl:param name="paramVal1" select="'default 1'"/>
<xsl:param name="paramVal2" />

<html>
<body>
  <xsl:value-of select="$paramVal1" />           <----- shows "default 1"
  <xsl:value-of select="$paramVal2" />           <----- doesn't show
anything
</body>
</html>

</xsl:template>
</xsl:stylesheet>

Current Thread