Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In you xsl create a <code>xsl:parameter</code> at the top before all your templates.</p> <pre><code>&lt;xsl:parameter name="showdate"/&gt; </code></pre> <p>You can now treat this like you would a variable:-</p> <pre><code>&lt;xsl:when test="@date = $showdate"&gt; </code></pre> <p>In order to pass a parameter in you need to use an XSL processor object which allows you to add the parameter before processing. In turn you get a processor from an instance of an XSL Template object. In turn you need a FreeThreadedDOMDocument to assign to the templates stylesheet parameter. Hence the code is more complex:-</p> <pre><code> Dim xsl : Set xsl = CreateObject("MSXML2.FreeThreadedDOMDocument.3.0") xsl.async = false xsl.load xslFile Dim xml : Set xml = CreateObject("MSXML2.DOMDocument.3.0") xml.async = false xml.load sourceFile Dim xslTemplate : Set xslTemplate = CreateObject("MSXML2.XSLTemplate.3.0") xslTemplate.stylesheet = xsl; Dim processor : Set processor = xslTemplate.createProcessor() processor.addParameter "showDate", "20091203" processor.input = source processor.transform() Response.Write processor.output </code></pre> <p>Its tempting to assign the Response object to the processor's output parameter which works quite well and is more efficient. However recent Service packs of MSXML have made such a technique incompatible with ASP's implementation of IStream in the Response object.</p> <p>So thats how you do it officially, how I do it normally is to inject some arbitary attribute on to the source XML's root node then use a variable:-</p> <pre><code>xml.documentElement.setAttribute("_showDate", "20091203") </code></pre> <p>Now you can use a variable instead of a parameter inside your main template:-</p> <pre><code>&lt;xsl:template match="rota"&gt; &lt;xsl:variable name="showdate" select="@_showDate" /&gt; &lt;html&gt; ... &lt;xsl:when test="@date = $showdate"&gt; </code></pre> <p>In this approach you can use the transform code you are already using which is much simpler.</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