ASP.NET - How to pass parameters to XSLT document

Pass parameters to XSLT document

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<%@ Import Namespace="System.Xml.XPath" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<script runat="server">
void Page_Load(object sender, System.EventArgs e)
    string xmlPath = Request.PhysicalApplicationPath + @"App_Data\ITBookList.xml";
    string xsltPath = Request.PhysicalApplicationPath + @"App_Data\ITBookList.xslt";
    XPathDocument xPathDoc = new XPathDocument(xmlPath);
    XslCompiledTransform transform = new XslCompiledTransform();
    XsltArgumentList xsltArgsList = new XsltArgumentList();
    xsltArgsList.AddParam("discount", "", ".50");
    transform.Transform(xPathDoc, xsltArgsList, Response.Output);
<html xmlns="" >
<head id="Head1" runat="server">
    <title> and XSLT - How to pass parameters to an XSLT document</title>
    <form id="form1" runat="server">

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
  <xsl:output method="html"/>
  <xsl:param name="discount" select=".25"/>
  <xsl:template match="/">
        <title>XSLT xsl:param - How to use parameter in xslt</title>
        <h2 style="color:Crimson; font-style:italic;"> and XSLT Example: Passing Parameters to XSLT File</h2>
        <hr width="700" align="left" color="Orange" />
        <br />
        <table border="1" cellpadding="5" cellspacing="0" bordercolor="Salmon">
          <tr bgcolor="DarkSalmon" style="color:White; font-weight:bold">
            <td>Book ID</td>
            <td>Name of Book</td>
            <td>Name of Author</td>
          <xsl:for-each select="books/book">
            <tr bgcolor="Snow" style="color:DeepPink; font-weight:normal">
              <td height="10">
                <xsl:value-of select="id"/>
              <td height="10">
                <xsl:value-of select="name"/>
              <td height="10">
                <xsl:value-of select="author"/>
              <td height="10">
                <xsl:value-of select="price"/>
              <td height="10" style="font-weight:bold;">
                <xsl:value-of select="price * ($discount)"/>

<?xml version="1.0" ?>
<!-- Sample XML file for various XML, XSLT, XPath example-->
  <book Category="XML and XSLT">
    <name>Beginning XML Databases</name>
    <author>Gavin Powell</author>
  <book Category="">
    <name>ASP.NET 3.5 Website Programming: Problem - Design - Solution</name>
    <author>Chris Love</author>
  <book Category="">
    <name>jQuery for ASP.NET Developers</name>
    <author>Joe Brinkman</author>
  <book Category="">
    <name>ASP.NET MVC 1.0 Test Driven Development: Problem - Design - Solution</name>
    <author>Emad Ibrahim</author>
  <book Category="XML and XSLT">
    <name>Beginning XSLT and XPath: Transforming XML Documents and Data</name>
    <author>Ian Williams</author>
  <book Category="XML and XSLT">
    <name>XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition</name>
    <author>Michael Kay</author>
  <book Category="Database">
    <name>Professional Microsoft SQL Server 2008 Programming</name>
    <author>Robert Vieira </author>
More examples