?
Solved

xsl datetime format with correct Timezone

Posted on 2005-05-03
2
Medium Priority
?
726 Views
Last Modified: 2008-01-09
Hi.
I am working with rss newsfeed and my xml data is something like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type='text/xsl' href='rssfeed.xsl'?>
<rss version="2.0">
  <channel>
    <title><![CDATA[News]]></title>
    <link>http://localhost</link>
    <description><![CDATA[blabla...]]></description>
    <language>no</language>
    <copyright>Copyright MHA</copyright>
    <managingEditor>webmaster</managingEditor>
    <generator>Webservice og DB</generator>
    <lastBuildDate>Tue, 03 May 2005 15:22:43 GMT</lastBuildDate>
    <item>
      <title><![CDATA[Test]]></title>
      <description><![CDATA[test]]></description>
      <pubDate>Sun, 24 Apr 2005 22:00:00 GMT</pubDate>
      <link>http://localhost?ItemID=1925</link>
      <guid>http://localhost?ItemID=1925</guid>
      <author>webmaster</author>
    </item>
  </channel>
</rss>
----------------------------------------------------------------------
My rssfeed.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
  <h2>My rss</h2>
    <table style="TABLE-LAYOUT: fixed" cellSpacing="0" cellPadding="0" width="100%" border="0" heihjt="100%">
      <tr bgcolor="#9acd32">
        <th align="left">News</th>        
      </tr>
      <xsl:for-each select="rss/channel/item">
      <tr>
       <td>
      <xsl:variable name="articleid"><xsl:value-of select="link"/></xsl:variable>
      <a href="{$articleid}"><xsl:value-of select="title"/></a>
       </td>
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>
-----------------------------------------------------
My question is how can I transform date and time format like this DD.MM.YYYY HH:mm:ss with a Norwegian Timezone(GMT+1) from the xml pubDate node.

Many thanks in advance!
Cheers,
MHA
0
Comment
Question by:michaenh
2 Comments
 
LVL 19

Accepted Solution

by:
ramazanyich earned 500 total points
ID: 13922569
in standard XSLT 1.0 you can't work with date formats.
But many popular XSLT processors support exslt.com extensions and that extensions have some functions which support manipualtion with dates. check http://exslt.org/date/index.html 
Which XSLT processor do you use?
0
 

Author Comment

by:michaenh
ID: 13924390
Hi.
I use standard XSLT 1.0.
So it is not possible? .. hm.. well I will check out with http://exslt.org/date/index.html.

Added this to the .xsl file:
<xsl:variable name="day" select="substring-before(substring-after($date, ' '), ' ')"/>
<xsl:variable name="monthName" select="substring-before(substring-after(substring-after($date, ' '), ' '), ' ')"/>
<xsl:variable name="month" select="substring(substring-after('Jan01Feb02Mar03Apr04May05Jun06Jul07Aug08Sep09Oct10Nov11Dec12', $monthName), 1, 2)"/>
<xsl:variable name="year" select="substring-before(substring-after(substring-after(substring-after($date, ' '), ' '), ' '), ' ')"/>
<xsl:variable name="Time" select="substring-before(substring-after(substring-after(substring-after(substring-after($date,' '),' '),' '),' '),' ')"/>
<xsl:value-of select="concat($day,'.',$month, '.',$year,' ',$Time)"/>

 I will get:
24.04.2005 22:00:00, but it s not the correct Timezone.

Thanks,
I'll be back.

Cheers,
MHA
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
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 Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline
Suggested Courses

839 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