EXSLT date:format-date template without document() XSLT 1.0

Posted by DashaLuna on Stack Overflow See other posts from Stack Overflow or by DashaLuna
Published on 2010-04-28T12:09:50Z Indexed on 2010/04/28 12:13 UTC
Read the original article Hit count: 405

Filed under:
|
|
|
|

Hello guys,

I'm using date:format-date template EXSLT file I'm using XSLT 1.0 and MSXML3.0 as the processor.

My date:format-date template EXSLT file's declaration is:

<xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:tui="http://www.travelbound.co.uk/"
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="msxsl tui date" 
version="1.0">
   ...
</xsl:stylesheet>

I cannot use document() function due to the 3rd party restrictions. So I have changed the months and days (similarly) from XML snippet:

<date:months>
  <date:month length="31" abbr="Jan">January</date:month>
  <date:month length="28" abbr="Feb">February</date:month>
  <date:month length="31" abbr="Mar">March</date:month>
  <date:month length="30" abbr="Apr">April</date:month>
  <date:month length="31" abbr="May">May</date:month>
  <date:month length="30" abbr="Jun">June</date:month>
  <date:month length="31" abbr="Jul">July</date:month>
  <date:month length="31" abbr="Aug">August</date:month>
  <date:month length="30" abbr="Sep">September</date:month>
  <date:month length="31" abbr="Oct">October</date:month>
  <date:month length="30" abbr="Nov">November</date:month>
  <date:month length="31" abbr="Dec">December</date:month>
</date:months>

to the variable:

 <xsl:variable name="months">
   <month length="31" abbr="Jan">January</month>
   <month length="28" abbr="Feb">February</month>
   <month length="31" abbr="Mar">March</month>
   <month length="30" abbr="Apr">April</month>
   <month length="31" abbr="May">May</month>
   <month length="30" abbr="Jun">June</month>
   <month length="31" abbr="Jul">July</month>
   <month length="31" abbr="Aug">August</month>
   <month length="30" abbr="Sep">September</month>
   <month length="31" abbr="Oct">October</month>
   <month length="30" abbr="Nov">November</month>
   <month length="31" abbr="Dec">December</month>
</xsl:variable>

And correspondingly, I've changed the code that originally uses document() function from:
[from month processing bit of EXSLT stylesheet]

<xsl:variable name="month-node" select="document('')/*/date:months/date:month[number($month)]" />

to use MSXML3.0 node-set function:

<xsl:variable name="month-node" select="msxsl:node-set($months)/month[number($month)]" />

So I assumed that this would work.

According to the EXLT instructions "The format pattern string is interpreted as described for the JDK 1.1 SimpleDateFormat class." [I used current version].

I'm specifing the month in accordance to SimpleDateFormat class as 'dd MMMMM yyyy' so that the month will be the full month's name, for example January. But it doesn't work :( I've looked in EXSLT stylesheet and it has got the logic to do that. Also there is logic to display the name of the week for a day using 'E' pattern, which doesn't work for me. Maybe changing from using document() to variables broke it.

Would really appreciate any help.

Many thanks!

© Stack Overflow or respective owner

Related posts about exslt

Related posts about date