Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I pass a parameter from ASP to XSL?
    text
    copied!<p>I'm writing a simple asp page to show a team rota based on some XML. Here's the XML:</p> <pre><code>&lt;rota&gt; &lt;shift date="20091201" primary="Chan" secondary="John" notes="notes"&gt;&lt;/shift&gt; &lt;shift date="20091202" primary="Mike" secondary="Alex" notes="notes"&gt;&lt;/shift&gt; &lt;shift date="20091203" primary="Ross" secondary="Mike" notes="notes"&gt;&lt;/shift&gt; &lt;shift date="20091204" primary="Neil" secondary="Ross" notes="notes"&gt;&lt;/shift&gt; &lt;/rota&gt; </code></pre> <p>I want my asp page to show today's rota details and maybe the details for the next couple of days. Since later on I'd like to be able to set a day in the future to see who's working around then I want to be able to pass a YYYYMMDD date from the ASP to the XSL that processes the XML.</p> <p>Here's the XSL I have so far, just highlighting the hardcoded 'current' date for now:</p> <p> </p> <pre><code>&lt;xsl:template match="rota"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Team Rota&lt;/title&gt; &lt;LINK type="text/css" rel="stylesheet" href="http://www.csfb.net/homepage/global/scripts/csfb_intranet.css"/&gt; &lt;/head&gt; &lt;body&gt; &lt;table border="1"&gt; &lt;TR&gt;&lt;TH&gt;Date&lt;/TH&gt;&lt;TH&gt;Primary&lt;/TH&gt;&lt;TH&gt;Secondary&lt;/TH&gt;&lt;TH&gt;Notes&lt;/TH&gt;&lt;/TR&gt; &lt;xsl:for-each select="shift"&gt; &lt;tr&gt; &lt;xsl:choose&gt; &lt;xsl:when test="@date = '20091203'"&gt; &lt;td bgcolor='FFF0F0'&gt;&lt;xsl:value-of select="@date"/&gt;&lt;/td&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;td&gt;&lt;xsl:value-of select="@date"/&gt;&lt;/td&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;td&gt;&lt;xsl:value-of select="@primary"/&gt;&lt;/td&gt; &lt;td&gt;&lt;xsl:value-of select="@secondary"/&gt;&lt;/td&gt; &lt;td&gt;&lt;xsl:value-of select="@notes"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/xsl:for-each&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; &lt;/xsl:template&gt; </code></pre> <p></p> <p>and here's the ASP, not yet passing any parameters:</p> <pre><code>''// Load the XML sourcefile = "rota.xml" set source = Server.CreateObject("Microsoft.XMLDOM") source.async = false source.load(sourceFile) ''// Load the XSL styleFile = Server.MapPath("rota.xsl") set style = Server.CreateObject("Microsoft.XMLDOM") style.async = false style.load(styleFile) htmltext = source.transformNode(style) Response.Write htmltext </code></pre> <p>So how do I a) pass a parameter to the XSL and b) pick up that parameter and use it in the XSL?</p> <p>Thanks for any guidance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload