Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

XSLT format-date() not recognised as a function.  What am I doing wrong

Posted on 2011-09-10
3
335 Views
Last Modified: 2012-05-12
I have an xml file with a date e.g
<expenseDate>2011-07-31T00:00:00</expenseDate> and I want to format it So iy reads
July 32, 2011.  When creating the stylesheet I tried the following
 <td>
      <xsl:value-of select="format-date(expenseDate, '[MNn] [D1], [Y]'])" />
 </td>
However I get an error when displaying the web page saying that format-date() is not a recognised function in XSLT (I am using version="2".  

Any help appreciated
0
Comment
Question by:ddefreitas
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 36515934
format-date() is a function that is only available in XSLT2.
It is not sufficient to label the version="2.0"
The processor you use should be able to process XSLT2 stylesheets

Since you tag this question with Visual Studio 2010, you are likely using MSXML and there is no version 2.0 support in MSXML
You could potentially use the .NET version of saxon (see www.saxonica.com)

The reason you don't get an error on teh version="2.0" is that XSLT processors are forward-wards compatible
So an XSLT1 stylesheet can run an XSLT2 stylesheet, but will report all unknown functionality unless there is a fallback
That is why you don't get a report about the stylesheet version, but only at the level of the function

There is no alternative for format-date in XSLT1.
But you can check for extensions that work for msxml in www.exslt.org
0
 

Author Closing Comment

by:ddefreitas
ID: 36516014
Thanks, very comprehensive explanation.  
Will try these but have managed to get the correct format from the database so will close this question
Kind regards
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36516168
welcome,
if data comes from a database it is always more advisable to do the formatting there.
XSLT1 is not fit for doing complex string manipulation, and there is no date format.
even in XSLT2 I find the date data model is a bit broken (or at least limited)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question