This is the mail archive of the mailing list .

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Passing parameters from ASP to XSL

Here is how I've passed parameters into XSL from ASP.

------------ Here's the ASP -----------
Dim xml, xsl
Dim XSLTemplate
Dim proc
	'put the XML in an object
	Set xml = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
	xml.async = False
	xml.loadXML XMLSourceFile

	'Load the XSL into an object
	Set xsl = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
	xsl.async = False
	xsl.Load Server.MapPath(XSLSourceFile)

	'add parameters to the xsl
	Set XSLTemplate = Server.CreateObject("MSXML2.XSLTemplate")
	Set XSLTemplate.stylesheet = xsl

	Set proc = XSLTemplate.createProcessor

	' Set the source of the data
	proc.input = xml
	proc.addParameter ParameterName, ParameterValue
	'more parameters...
	Response.Write proc.output

	'clean up
	Set xml = Nothing
	Set xsl = Nothing
	Set proc = Nothing
	Set XSLTemplate = Nothing

---------- Here are the key parts of the XSL ----------
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="";

	<xsl:param name="SID" select="/.."/>
	[other parameters...]
	<xsl:output method="html" indent="yes"/>

	<xsl:template match="/">
		<table cellspacing="0" cellpadding="1" border="0">
			<xsl:apply-templates select="//Holding"/>
		<xsl:call-template name="NextPrevLinks"/>

	[Other Templates...]


-----Original Message-----
From: []
Sent: Saturday, March 17, 2001 6:03 PM
Subject: [xsl] Passing parameters from ASP to XSL

Hi there,

I'm fairly new to XSL and ASP, too. After hours, I managed to transform a
XML document into an HTML document using ASP and XSL. Now, I'm trying to
pass a
parameter from the ASP to the XSL-File (background: I have an article in the
XML-File and I want to render only one page at a time to the browser, the
parameter will specify which page). I've got two problems:
First, I tried an example from the mulberry list archive, but it doesn't
work from ASP-side.

	Set template=createObject("MSXML2.XSLTemplate")
	Set template.stylesheet=addRecordFilter
	Set processor=template.createProcessor

	for each qs in Request.QueryString()
		processor.AddParameter qs,Request.QueryString(qs)

In the second line of code, the processor says, that an object is needed. 

Second, I'm using PWE and MSXML3 to do the transformations. I used the
namespace and it works fine, renders a ToC and
highlights one of the items, selected by and constant integer (this will be
by the passed parameter, I thought):

<?xml version="1.0"?>
<HTML xmlns:xsl="";>
    <LINK REL="stylesheet" TYPE="text/css" HREF="style.css"/>
    <UL ID="toc">
    <xsl:for-each select="article/chapter">
        <xsl:when test="context()[2]">
            <xsl:value-of select="title"/>
            <xsl:attribute name="class">subtitle_small</xsl:attribute>
            <xsl:value-of select="title"/>
<!-- TOC ENDS HERE -->


I've read, that passing parameters are only working with the namespace, but if I change the namespace to this,
says, that I cannot use HTML within this namespace. If I use <xsl:param>
the namespace given in the sample source above, it says, that I may not use
the <xsl:param>. Frustrating, I think.

I think, I need a good pointer into the right direction now. What do I have
to change to insert a param into the xsl and how do I add the parameter's
value from the ASP's side? Any examples on the web that will run on my
Web Server and MSXML3? I have to use these tools because of an assessment
my university.

Any comments are highly appreciated

Sebastian Will

Sent through GMX FreeMail -

 XSL-List info and archive:

 XSL-List info and archive:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]