Hi,
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 & 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