Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 487727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:38:05+00:00 2026-05-13T01:38:05+00:00

I’m writing a simple asp page to show a team rota based on some

  • 0

I’m writing a simple asp page to show a team rota based on some XML. Here’s the XML:

<rota>
<shift date="20091201" primary="Chan" secondary="John" notes="notes"></shift>
<shift date="20091202" primary="Mike" secondary="Alex" notes="notes"></shift>
<shift date="20091203" primary="Ross" secondary="Mike" notes="notes"></shift>
<shift date="20091204" primary="Neil" secondary="Ross" notes="notes"></shift>
</rota>

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.

Here’s the XSL I have so far, just highlighting the hardcoded ‘current’ date for now:

<xsl:template match="rota">
    <html>
    <head>
        <title>Team Rota</title>
        <LINK type="text/css" rel="stylesheet" href="http://www.csfb.net/homepage/global/scripts/csfb_intranet.css"/> 
    </head>
    <body>
    <table border="1">
    <TR><TH>Date</TH><TH>Primary</TH><TH>Secondary</TH><TH>Notes</TH></TR>
    <xsl:for-each select="shift">
        <tr>
            <xsl:choose>
                <xsl:when test="@date = '20091203'">
                    <td bgcolor='FFF0F0'><xsl:value-of select="@date"/></td>
                </xsl:when>
                <xsl:otherwise>
                    <td><xsl:value-of select="@date"/></td>
                </xsl:otherwise>
            </xsl:choose>
            <td><xsl:value-of select="@primary"/></td>
            <td><xsl:value-of select="@secondary"/></td>
            <td><xsl:value-of select="@notes"/></td>
        </tr>       
    </xsl:for-each>
    </table>
    </body>
    </html>
</xsl:template>

and here’s the ASP, not yet passing any parameters:

''// 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

So how do I a) pass a parameter to the XSL and b) pick up that parameter and use it in the XSL?

Thanks for any guidance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:38:06+00:00Added an answer on May 13, 2026 at 1:38 am

    In you xsl create a xsl:parameter at the top before all your templates.

    <xsl:parameter name="showdate"/>
    

    You can now treat this like you would a variable:-

    <xsl:when test="@date = $showdate">
    

    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:-

     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
    

    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.

    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:-

    xml.documentElement.setAttribute("_showDate", "20091203")
    

    Now you can use a variable instead of a parameter inside your main template:-

    <xsl:template match="rota">
      <xsl:variable name="showdate" select="@_showDate" />
        <html> ...
             <xsl:when test="@date = $showdate">
    

    In this approach you can use the transform code you are already using which is much simpler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.