Answered this very question yesterday... heres my answer from then... the
same code will work for you...
Heres a sample using C#.
<%@ Page Trace="false" Language="C#" Debug="false" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Xml" %>
<%@ import Namespace="System.Xml.XPath" %>
<%@ import Namespace="System.Xml.Xsl" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e){
XsltArgumentList xslArg = new XsltArgumentList();
xslArg.AddParam("nameOfParam", "", "valueOfParam");
//continue adding parameters in this matter until your done
//Create a resolver and set the credentials to use.
//this gives you the ability to use things like the document()
function
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = CredentialCache.DefaultCredentials;
// Load the XML document to transform.
XPathDocument doc = new XPathDocument(Server.MapPath("test.xml"));
// Load the stylesheet and perform the transform.
XslTransform xslt = new XslTransform();
xslt.Load(Server.MapPath(test.xslt));
xslt.Transform(doc, xslArg, Response.OutputStream, resolver);
}
</script>
<html>
<head>
<title/>
</head>
<body>
<form runat=server>
</form>
</body>
</html>
This should get you to where you want to go...
Best regards,
M.
----- Original Message -----
From: "Riju Abraham" <R(_dot_)Abraham(_at_)jandp(_dot_)com(_dot_)sa>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Saturday, January 17, 2004 12:02 AM
Subject: [xsl] Passing Parameters to XSL
Hi All,
Does any one have an aspx code to pass a parameter to an XSL
I am hereby giving My XML and XSl ....I want to perform a dynamic sorting
depending on which Col Header the User clicks.
I am new to please.Please do help with all suggetsions.If any body has the
aspx code also please do forward it.
Thanks in advance..
<xsl:transform version="1.0"
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:msxsl ="urn:schemas-microsoft-com:xslt">
<xsl:output method="html"></xsl:output>
<xsl:param name ="sortBy">country</xsl:param>
<xsl:template match="/">
<html>
<body>
<div align ="left">
Sort By:
<xsl:value-of select="$sortBy"></xsl:value-of>
</div>
<table width="210" border="2pt" cellspacing="0" cellpadding="3"
bordercolor="#dddddd" style="border-collapse:collapse;">
<tr bgcolor="#9acd32">
<th align="Left"><a class="clickanchor"
onclick="ClickedMe('Country');" >Country</a></th>
<th align="Left"><a class="clickanchor"
onclick="ClickedMe('AreaCode');" >AreaCode</a></th>
<th align="Left"><a class="clickanchor"
onclick="ClickedMe('AreaDescription');">AreaDescription</a></th>
</tr>
<xsl:for-each select ='locations/area'>
<xsl:sort select="areadescription"/>
<tr>
<td class="Normal">
<center>
<xsl:value-of select ='country'/>
</center>
</td>
<td class="Normal">
<center>
<xsl:value-of select ='areacode'/>
</center>
</td>
<td class="Normal">
<left>
<xsl:value-of select
='areadescription'/>
</left>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:transform>
--------------------------------------------------------------------------
--
------------------------------------
<?xml version="1.0" ?>
<locations>
<area>
<country>KSA</country>
<areacode>A</areacode>
<areadescription>ABHA AREA
</areadescription>
</area>
<area>
<country>KSA</country>
<areacode>D</areacode>
<areadescription>DHAHRAN AREA
</areadescription>
</area>
<area>
<country>KSA</country>
<areacode>F</areacode>
<areadescription>TAIF AREA
</areadescription>
</area>
<area>
<country>KSA</country>
<areacode>H</areacode>
<areadescription>HARADH AREA
</areadescription>
</area>
<area>
<country>KSA</country>
<areacode>J</areacode>
<areadescription>JEDDAH AREA
</areadescription>
</area>
</locations>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list