0

I would like to display current date with the following format. However using current-date() is throwing error "Failed to apply XSLT" Thu 02 Mar 2017

The following is the code that i have so far. Thank you

 <?xml version="1.0"?>

<xsl:stylesheet 
  version="1.0" 
  exclude-result-prefixes="x d xsl msxsl cmswrt"
  xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
  xmlns:x="http://www.w3.org/2001/XMLSchema" 
  xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" 
  xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  xmlns:w="http://rss.weather.com.au/w.dtd">

  <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>

<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />




<xsl:template match="/">



<div id="top" >


        <div class="weather rendered">

            <xsl:attribute name="onclick">OpenPopUpPage('<xsl:value-of select="/rss/channel/link"/>')</xsl:attribute>
            <xsl:attribute name="title">Current temperature: <xsl:value-of select="/rss/channel/item/w:current/@temperature"/>° &#xD;City forecast for <xsl:value-of select="/rss/channel/item/w:forecast[1]/@day"/>:&#xD;<xsl:value-of select="/rss/channel/item/w:forecast[1]/@min"/>&#176;-<xsl:value-of select="/rss/channel/item/w:forecast[1]/@max"/>&#176;, <xsl:value-of select="/rss/channel/item/w:forecast[1]/@description"/></xsl:attribute>

            <div class="max"><xsl:value-of select="format-number(/rss/channel/item/w:current/@temperature, '0')"/><span class="deg">&#176;</span></div>

            <div><xsl:value-of select="ddwrt:FormatDateTime(string(@CurrentDate) ,1033 ,'MMM yyyy')"/></xsl:value-of> </div>

        </div>



</div>
</xsl:template>



</xsl:stylesheet>

Note: if I used the following it work fine, but it will display date in GMT not local date which is 11 hours ahead.

  <div class="date"><xsl:value-of select="substring(/rss/channel/item/pubDate,1,16)"/></div>
0

You can try this code below:

<xsl:value-of select="formatDateTime(string(/rss/channel/item/w:current/@dateFieldParameter) ,1033 ,'MMM yyyy')"/>

This must work for you..

  • i have updated the question as your suggestion but still not working – Supermode Mar 14 '17 at 4:55
  • kindly add whole xslt of your data view web part..this might help in targeting the error – Ankitkumar Malde Mar 14 '17 at 6:14
  • i am not using dataview webpart. I am using XSL to read rss feed. that is the whole xsl. thanks – Supermode Mar 14 '17 at 6:18
  • can u now try please...replace dateFieldParameter by parameter name from RSS feed – Ankitkumar Malde Mar 14 '17 at 8:47
  • Thanks Ankitkumar, the problem is i need to get local timezone. The current pubDate in RSS using GMT. Local timezone is 11 hours ahead. That is why i want to achieve using currentDate function which not available in XSLT 1.0 – Supermode Mar 14 '17 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.