Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: trying to separate and reformat the date and time

From: "Dimitre Novatchev" <dimitren@---.---.-->
To: NULL
Date: 2/6/2007 8:01:00 PM

See my Calendar XSLT application, written almost five years ago. It uses the 
datetime library (datetime_lib.xsl), distributed with XSelerator. This is a 
library of XSLT 1.0 templates for working with dates and times. One can get 
it either by buying the XSelerator or by downloading its trial version.

The link to the Calendar application is:

     http://www.topxml.com/code/default.asp?p=3&id=v20020711152545

Of course, such kind of transformations are now easier with XSLT 2.0.

Cheers,
Dimitre Novatchev


"Chuck" <techserv-no-spam-for-me@topsecurityinc-dotcom> wrote in message 
news:eGU9VKmSHHA.3440@T......
> Hello,
>
> I need to take the below listed date and time in the XML and convert it 
> using XSL into a separate date and time element using the below mentioned 
> formats without the use of a function so that it is processor independent.
>
> Any ideas would be appreciated
>
> XML
>
> <ds_EventHistory xmlns="http://tempuri.org/ds_EventHistory.xsd">
>    <EventHistory>
> <Event_Date>2006-03-01 07:27:15</Event_Date>
> </EventHistory>
> </ds_EventHistory>
>
> XSL - Not sure how to modify this code to get the below listed date format 
> (it needs to also handle the day of the week)
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
>    xmlns:sd="http://tempuri.org/ds_EventHistory.xsd"
>    exclude-result-prefixes="sd"
>    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>    xmlns:user="https://www.domain.com/mynamespace">
>
> <xsl:template name="long_date">
> <xsl:param name="date" />
> <!-- Day -->
> <xsl:value-of select="number(substring($date, 7, 2))" />
> <xsl:text> </xsl:text>
> <!-- Month -->
> <xsl:variable name="month"
>     select="number(substring($date, 5, 2))"/>
> <xsl:choose>
>  <xsl:when test="$month=1">January</xsl:when>
>  <xsl:when test="$month=2">February</xsl:when>
>  <xsl:when test="$month=3">March</xsl:when>
>  <xsl:when test="$month=4">April</xsl:when>
>  <xsl:when test="$month=5">May</xsl:when>
>  <xsl:when test="$month=6">June</xsl:when>
>  <xsl:when test="$month=7">July</xsl:when>
>  <xsl:when test="$month=8">August</xsl:when>
>  <xsl:when test="$month=9">September</xsl:when>
>  <xsl:when test="$month=10">October</xsl:when>
>  <xsl:when test="$month=11">November</xsl:when>
>  <xsl:when test="$month=12">December</xsl:when>
>  <xsl:otherwise>INVALID MONTH</xsl:otherwise>
> </xsl:choose>
> <xsl:text> </xsl:text>
> <!-- Year -->
> <xsl:value-of select="substring($date, 1, 4)" />
>
> </xsl:template>
> </xsl:stylesheet>
>
>           <td>
>                <xsl:value-of select="sd:Event_Date"/>  <------------ This 
> should be the date
>                <xsl:text>&#160;</xsl:text>
>            </td>
> Date needs to look like this format...
> Wednesday, March 01, 2006
>
>
>            <td>
>                <xsl:value-of select="sd:Event_Date"/>  <------------ This 
> should be the time
>                <xsl:text>&#160;</xsl:text>
>            </td>
> Time needs to look like this format...
> 7:27:15am
>
> Thank you in advance.
>
>
>
> 




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent