I added the EXSLT dates-and-times module in my XSLT 1.0 file by declaring:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ... xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date">
This doesn't affect my resulting page, but when I try to call the actual date with:
<xsl:value-of select="date:date-time()"/>
I receive an "Error loading stylesheet: An unknown error has occurred ()" message when loading my page. Does anyone have a suggestion as to what I might be missing? Thanks in adv开发者_如何学运维ance!
but when I try to call the actual date with:
<xsl:value-of select="date:date-time()"/>
I receive an "Error loading stylesheet: An unknown error has occurred ()" message when loading my page
This means that the particular XSLT processor you're using doesn't implement EXSLT (or just the date-time module of EXSLT).
Here is a small transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
>
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:value-of select="date:date-time()"/>
</xsl:template>
</xsl:stylesheet>
when applied to any XML document (not used), with the Saxon 6.5.4 XSLT 1.0 processor, the correct result is produced:
2010-05-22T12:49:44-07:00
Solution:
Either use an XSLT 1.0 processor that implements EXSLT, or pass the current date-time as a parameter to the transformation.
If using XSLT 2.x, just use the XPath 2.0 function current-dateTime()
.
精彩评论