Click to See Complete Forum and Search --> : Using Date Formatting functions with XSL


cszalaj
01-05-2010, 10:35 AM
I am trying to use the format-dateTime() function in an xsl transformation, but I am missing something to enable it. Sort of new to xsl, so I can't figure it out. The code works without the formatting funciton, but I want to format the date. Here is the code, what do I need to include to make the function work? A different namespace? Import an external doc/library? The XSL 2.0 reference says that this is a standard xsl function. The format-dateTime() funciton is used toward the bottom.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
>

<xsl:output method="html" indent="yes" encoding="utf-8" omit-xml-declaration="yes"/>

<xsl:template match="/">
<table width="500px" border ="0" cellpadding="5px">
<xsl:for-each select="//GetProductionsResult/Production">
<xsl:sort select="first_dt"/>
<xsl:variable name ="prod_id" select="prod_season_no" />
<xsl:variable name ="first_dt" select="first_dt" />
<xsl:variable name ="last_dt" select="last_dt" />
<xsl:variable name ="image" select="//GetProductionsResult/WebContent[content_type='8' and inv_no=$prod_id]/content_value" />
<xsl:variable name ="title" select="//GetProductionsResult/WebContent[content_type='14' and inv_no=$prod_id]/content_value" />
<xsl:variable name ="presenter" select="//GetProductionsResult/WebContent[content_type='30' and inv_no=$prod_id]/content_value" />
<tr>
<td valign="top" width="60px">
<a href="http://patron.tpac.org/main.taf?p=9,5,1&amp;ProductionID={$prod_id}">
<img src="http://patron.tpac.org/img/shared/{$image}" width="85" height="85" border="0"/>
</a>
<br />
<a href="http://patron.tpac.org/main.taf?p=9,5,1&amp;ProductionID={$prod_id}&amp;showTickets=1">
<img src="http://tpac.org/images/BuyTickets-1.gif" border="0"/>
</a>
</td>
<td valign="top">
<xsl:value-of select='$presenter' /> presents:<br/>
<strong>
<xsl:value-of select='$title' />
</strong><br />
<xsl:value-of select="format-dateTime($first_dt,'[FNn], [MNn] [D], [h]:[m] [P]')" /> to <xsl:value-of select='last_dt' /><br />
<xsl:value-of select='synopsis' />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

rnd me
01-07-2010, 05:56 PM
The XSL 2.0 reference says that this is a standard xsl function.

there aren't very many xslt2 processors out there, which one are you using to do the transforms?

cszalaj
01-08-2010, 03:51 PM
This will give you an idea of how little i know about this yet: I don't know which processor I am using.

We are .NET 3.5, so whatever xslt processor is part of our existing framework by default is what we are using. It very well could be that it is not an xslt2 processor.

DO you have any recommendations about what I should use? I've done a bit of looking and it seems Saxon might be a good choice. Thanks for the response -

rnd me
01-09-2010, 01:15 PM
This will give you an idea of how little i know about this yet: I don't know which processor I am using.

We are .NET 3.5, so whatever xslt processor is part of our existing framework by default is what we are using. It very well could be that it is not an xslt2 processor.

DO you have any recommendations about what I should use? I've done a bit of looking and it seems Saxon might be a good choice. Thanks for the response -

i can't recommend any from experience, but i know M$'s not on the xslt2.0 bandwagon yet. it was supposed to make 3.5, but it didn't...