I am trying to use date and time in xsl 1.0 I tried to follow this solution: Can an XSLT insert the current date?
But I get an error saying: Error loading stylesheet: An unknown error has occurred (805303f4)
It does not tell me where the error is, so I'm kinda stuck.
In my xml file, here is my declaration to the namespace:
<?xml version="1.0" encoding="UTF-8"?>
<!-- xsl stylesheet declaration with xsl namespace:
Namespace tells the xlst processor about which element is to be processed and
which is used for output purpose only
-->
<xsl:stylesheet version="1.0"
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="date"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="date.xsl" />
And this is how I am trying to get the time and date:
<xsl:message terminate="no">
here: <xsl:value-of select="date:date-time()"/>
</xsl:message>
I downloaded the date and time package on github.
I am not sure what I am doing wrong. I have not changed anything in the files downloaded from Github
----------------------------Update-------------- Here is the entire xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- xsl stylesheet declaration with xsl namespace:
Namespace tells the xlst processor about which element is to be processed and
which is used for output purpose only
-->
<xsl:stylesheet version="1.0"
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="date"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="date.xsl" />
<!-- xsl template declaration:
template tells the xlst processor about the section of xml document which is to be
formatted. It takes an XPath expression.
In our case, it is matching document root element and will tell processor to
process the entire document with this template.
-->
<xsl:template match="/">
<!-- HTML tags
Used for formatting purpose. Processor will skip them and browser will simply
render them.
-->
<html>
<body>
<h2>Students</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Roll No</th>
<th>First Name</th>
<th>Last Name</th>
<th>Nick Name</th>
<th>Marks</th>
</tr>
<!-- for-each processing instruction
Looks for each element matching the XPAth expression
-->
<xsl:message terminate="no"> hello </xsl:message>
<xsl:for-each select="class/student">
<xsl:sort select="@rollno"/>
<xsl:if test="marks >= 85">
<xsl:message terminate="no"> her: <xsl:value-of select="date:date-time()"/> </xsl:message>
<tr>
<td>
<!-- value-of processing instruction
process the value of the element matching the XPath expression
-->
<xsl:value-of select="@rollno"/>
</td>
<td><xsl:value-of select="firstname"/></td>
<td><xsl:value-of select="lastname"/></td>
<td><xsl:value-of select="nickname"/></td>
<td><xsl:value-of select="marks"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
And here is the date.xsl file:
<?xml version="1.0" encoding="utf-8"?>
<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/Dates and Times" version="1.0" extension-element-prefixes="date" date:doc="http://www.exslt.org/date">
<import href="functions/date-time/date.date-time.xsl"/>
<import href="functions/date/date.date.xsl"/>
<import href="functions/time/date.time.xsl"/>
<import href="functions/year/date.year.xsl"/>
<import href="functions/leap-year/date.leap-year.xsl"/>
<import href="functions/month-in-year/date.month-in-year.xsl"/>
<import href="functions/month-name/date.month-name.xsl"/>
<import href="functions/month-abbreviation/date.month-abbreviation.xsl"/>
<import href="functions/week-in-year/date.week-in-year.xsl"/>
<import href="functions/day-in-year/date.day-in-year.xsl"/>
<import href="functions/day-in-month/date.day-in-month.xsl"/>
<import href="functions/day-of-week-in-month/date.day-of-week-in-month.xsl"/>
<import href="functions/day-in-week/date.day-in-week.xsl"/>
<import href="functions/day-name/date.day-name.xsl"/>
<import href="functions/day-abbreviation/date.day-abbreviation.xsl"/>
<import href="functions/hour-in-day/date.hour-in-day.xsl"/>
<import href="functions/minute-in-hour/date.minute-in-hour.xsl"/>
<import href="functions/second-in-minute/date.second-in-minute.xsl"/>
<import href="functions/format-date/date.format-date.xsl"/>
<import href="functions/parse-date/date.parse-date.xsl"/>
<import href="functions/week-in-month/date.week-in-month.xsl"/>
<import href="functions/difference/date.difference.xsl"/>
<import href="functions/add/date.add.xsl"/>
<import href="functions/add-duration/date.add-duration.xsl"/>
<import href="functions/sum/date.sum.xsl"/>
<import href="functions/seconds/date.seconds.xsl"/>
<import href="functions/duration/date.duration.xsl"/>
</stylesheet>