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&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&ProductionID={$prod_id}&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>
<?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&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&ProductionID={$prod_id}&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>