Jump to content

Problem with format-date


ChuTri

Recommended Posts

Hi all,I want to get day ( Mon, Tue, Wed .... ) from date ( 2/2/2010 ). I use folow coding in my xsl file

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="2.0"   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:xs="http://www.w3.org/2001/XMLSchema"   >  <xsl:template match="/">	<html>	  <body>  		<xsl:variable name="date2" select="xs:date('2005-03-01')"/>		<xsl:value-of select="format-date($date2,'[F]')"/>	  </body>	</html>  </xsl:template></xsl:stylesheet>

But when open xml file ( that embedded xsl file ) for running, i receive error :

Namespace 'http://www.w3.org/2001/XMLSchema' does not contain any functions.

How could i solve it ?

Link to comment
Share on other sites

Functions like xs:date and format-date are only supported by XSLT 2.0 processors, not by XSLT 1.0 processors. So probably you are simply using the wrong software to run your stylesheet. Known XSLT 2.0 processors are Saxon 9, AltovaXML Tools, XQSharp 2.0. Intel and IBM also have XSLT 2.0 processors.
So, is there anyways that could i get day ( Mon, Tue, Wed ... ) from date in xslt 1.0 ?
Link to comment
Share on other sites

You could check whether your XSLT 1.0 processor supports http://www.exslt.org/date/index.html. It has functions like http://www.exslt.org/date/functions/day-in-week/index.html or http://www.exslt.org/date/functions/day-name/index.html.Other options are using extension functions or objects, for instance an XSLT processor like the .NET System.Xml.Xsl.XslCompiledTransform can with the help of extension functions or objects use the .NET framework's class library date support. Or an XSLT processor implemented in Java usually allows extension functions to use Java APIs.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...