EXSLT Date Functions
reclusive monkey <[email protected]>
| Newsgroups | gmane.text.xml.xslt.extensions |
|---|---|
| Message-ID | <[email protected]> |
Hello, I have been tinkering with XML and XSLT for a few months now, and I have got stuck on date formatting. I am exporting a table from MS Access, which gives me the following XML file (edited for brevity); <?xml version="1.0" encoding="UTF-8"?> <dataroot xmlns:od="urn:schemas-microsoft-com:officedata"> ... <tblPeriods> <PeriodID>10</PeriodID> <FLYear>2004/05</FLYear> <FLMonitor>1</FLMonitor> <ExtractDate>2004-06-30T00:00:00</ExtractDate> <Note>1st Monitor</Note> <Cycle>July</Cycle> <FLMonth>June</FLMonth> </tblPeriods> ... </dataroot> Yes, well spotted, once I get the date functions working I can use these to provide "Cycle" and "FLMonth" :-) I have created the following XSL style sheet to format the XML file; <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dt="urn:schemas-microsoft-com:datatypes" xmlns:date="http://exslt.org/date" xmlns:str="http://exslt.org/str" extension-element-prefixes="date str" > <xsl:template match="/"> <html> <head> <link rel="stylesheet" href="XMLSTYLE.CSS" type="text/css" /> <title>SCSD Budget Monitoring Timetable</title> </head> <body> <h1>SCSD Finance Department</h1> <h2>Budget Monitoring Timetable</h2> <table> <thead><td width="10%">Number</td><td width="10%">Cycle</td><td width="10%">FL Month</td><td width="10%">Monitors Issued</td><td width="10%">Monitors Returned</td><td width="10%">DMT</td><td width="10%">CFO</td><td width="10%">Cabinet</td><td width="10%">Scrutiny</td><td width="10%">FL Year</td></thead> <xsl:for-each select="//tblPeriods"> <xsl:if test="FLYear='2005/06'"> <xsl:if test="FLMonitor>='1'"> <tr> <td><xsl:apply-templates select="FLMonitor" /></td> <td><xsl:apply-templates select="Cycle" /></td> <td><xsl:apply-templates select="FLMonth" /></td> <td><xsl:apply-templates select="MonitorsIssued" /></td> <td><xsl:apply-templates select="MonitorsReturned" /></td> <td><xsl:apply-templates select="DMT" /></td> <td><xsl:apply-templates select="CFO" /></td> <td><xsl:apply-templates select="Cabinet" /></td> <td><xsl:apply-templates select="Scrutiny" /></td> <td><xsl:apply-templates select="FLYear" /></td> </tr> </xsl:if> </xsl:if> </xsl:for-each> <tfoot><td colspan="10"></td></tfoot> </table> </body> </html> </xsl:template> </xsl:stylesheet> I downloaded "date.zip" and "str.zip" (I believe I need str functions for date), and unpacked them in the root dir of where my XML/XSL pages are. However, when I add the line "<xsl:import href="date/date.xsl" />", IE6 gives me "Line: 38, Character: 4, Error: Keyword import may not be used here". I am puzzled as to where to go from here. Do I need to import both date.xsl and str.xsl to get the date functions (date-format is what I want; I need the "<ExtractDate>2004-06-30T00:00:00</ExtractDate>" to be in a UK date format without the time. Whatever I do, I cannot get access to simply export the date alone (without the time) or in a UK date format. Simple explanations please, as I am a bear of very little brain and large words bother me... Thanks in advance. Luke P.S. I work for the public sector. Its all got to be done very simply on the client side. Just in case it matters, I am applying the XSL stylesheet through a HTTP page with a bit of JavaScript.