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 961379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:20:05+00:00 2026-05-16T01:20:05+00:00

Hopefully this will be a simple fix. I’m completely new to XSL but I’ve

  • 0

Hopefully this will be a simple fix. I’m completely new to XSL but I’ve managed to get a little script that sorts my data by date. I now want to use ASP to limit this data to all entries within a month (this works by using a DateDiff() function). When I go to load in the XSL scripts output it says that my XML is malformed. Can anyone help me out here please?

Here’s my XML File:

<?xml version="1.0"?>
<Rota>
   <Shift>
      <date>23/07/2010</date>
      <title1>GM Neurosciences</title1>
      <gm>Katie Cusick</gm>
      <title2>Chief Operating Officer</title2>
      <director>Patrick Mitchell</director>
      <nurse>n/a</nurse>
    </Shift>
    <Shift>
      <date>30/07/2010</date>
      <title1>GM Specialised Medicine</title1>
      <gm>Alison Watson</gm>
      <title2>DDO Medicine &amp; Cardio.</title2>
      <director>Suzanne Marsello</director>
      <nurse>n/a</nurse>
    </Shift>
</Rota>

Here’s my XSL File:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:output method="xml" omit-xml-declaration="no" version="1.0" />
   <xsl:param name="sortBy" select="'date'"/>
   <xsl:param name="strXPath" select="//Shift"/>
   <xsl:template match="/"> 
      <xsl:apply-templates select="$strXPath">
               <xsl:sort select="substring(date,7,4)"/> <!-- year sort -->
               <xsl:sort select="substring(date,4,2)"/> <!-- month sort -->  
               <xsl:sort select="substring(date,1,2)"/> <!-- day sort -->
          </xsl:apply-templates>
   </xsl:template>
   <xsl:template match="Shift"> 
       <Shift>
           <date><xsl:value-of select="date"/></date>
           <title1><xsl:value-of select="title1"/></title1>
           <gm><xsl:value-of select="gm"/><gm>
           <title2><xsl:value-of select="title2"/></title2>
           <director><xsl:value-of select="director"/></director>
           <nurse><xsl:value-of select="nurse"/></nurse>
       </Shift>
    </xsl:template>
</xsl:stylesheet>

And Here’s my ASP Code:

<%

Set entries = Server.CreateObject("Microsoft.XMLDOM")
Set entry = Server.CreateObject("Microsoft.XMLDOM")
Set xml = Server.CreateObject("Microsoft.XMLDOM")
Set xsl = Server.CreateObject("Microsoft.XMLDOM")
Set newxml = Server.CreateObject("Microsoft.XMLDOM")

xml.async = False
xml.load (Server.MapPath("rota.xml"))

xsl.async = False
xsl.load(Server.MapPath("indexrota.xsl"))
newxml.async = False
newxml.load(xml.transformNode(xsl))

set entries = newxml.getElementsbyTagName("Shift")
noOfEntries = entries.length
startDate = "15/07/2010"
LastDate = DateAdd("m",1,date())


Response.Write("<table><tr><th>Date</th><th>Title</th><th>GM</th><th>Title</th><th>Director</th><th>Nurse / Matron</th></tr>")
For i = 0 To (noOfEntries - 1)
    Set entry = entries.item(i)
    If isDate(entry.childNodes(0).text) Then
        meh = CDate(entry.childNodes(0).text)
        beginning = DateDiff("d", meh, startDate)
        ended = DateDiff("d", meh, LastDate)
        If beginning + 1 <= 0 And ended >= 0 Then
            Response.Write("<tr>"&_
            "<td>" & entry.childNodes(0).text & "</td>"&_
            "<td>" & entry.childNodes(1).text & "</td>"&_
            "<td>" & entry.childNodes(2).text & "</td>"&_
            "<td>" & entry.childNodes(3).text & "</td>"&_
            "<td>" & entry.childNodes(4).text & "</td>"&_
            "<td>" & entry.childNodes(5).text & "</td>"&_
            "</tr>")
            End If
        End If
    Next
    Response.Write("</table>")
%>

I’m sure it’s a case of the XSL because the ASP has worked perfecton the XML before

  • 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-16T01:20:05+00:00Added an answer on May 16, 2026 at 1:20 am

    There are two problems with your XSL.

    Firstly, where you copy the gm element, you have not correctly closed off the gm tag.

    <gm><xsl:value-of select="gm"/><gm> 
    

    This should become

    <gm><xsl:value-of select="gm"/></gm> 
    

    Secondly, althuogh you are copying the Shift elements, your resultant XML does not contain a root element. You need to put a Rota element outside your xsl:apply-templates call

    <xsl:template match="/"> 
       <Rota>  
           <xsl:apply-templates select="$strXPath">  
               <xsl:sort select="substring(date,7,4)"/> <!-- year sort -->  
               <xsl:sort select="substring(date,4,2)"/> <!-- month sort -->    
               <xsl:sort select="substring(date,1,2)"/> <!-- day sort -->  
            </xsl:apply-templates>  
        </Rota>
    </xsl:template>  
    

    Note that you can simplify the copying of the Shift element, simply by doing this

    <xsl:template match="Shift">  
       <xsl:copy-of select="." />
    </xsl:template> 
    

    There is also a problem with the ASP code. The line newxml.load(xml.transformNode(xsl)) is incorrect. Because transformNode returns a string containing the XML, you really need to do the following

    newxml.loadXml(xml.transformNode(xsl))
    

    Use load when loading xml from a file. Use loadXml when loading a string containing Xml

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

Sidebar

Related Questions

New to MVC, so hopefully this will be pretty simple. I have an HTML
Hopefully this will be one of those simple answers that is so simple they
Hopefully this will be simple. But I've hunted for a couple hours now and
Hopefully this is a simple request. I found this code that will work perfectly
This will hopefully be a simple one: I have a div I want to
Hopefully this explanation will make sense, but what is the best way (if it
I will do my best to explain this. Hopefully my notes in script will
I'm fairly new to Joomla - so hopefully this isn't too simple. My client
I have just started looking at javascript so hopefully this will be something simple.
Hopefully this is a simple one, but can anyone provide some simple c# code

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.