开发者

EXSLT template date:format-date works incorrectly after template date:add

开发者 https://www.devze.com 2023-02-05 05:32 出处:网络
The following code <td> <xsl:call-template name=\"date:add\"> <xsl:with-param name = \"date-time\"select =\"hml:LT\" />

The following code

<td>
    <xsl:call-template name="date:add">
      <xsl:with-param name = "date-time"  select ="hml:LT" />
      <xsl:with-param name = "duration"   select = "'PT1H'" />
    </xsl:call-template>
  </td>
  <td>
    <xsl:call-template name="date:format-date">
      <xsl:with-param name = "date-time"  select ="hml:LT" />
      <xsl:with-param name = "pattern"   select = "'dd, MMM yyyy'" />
    </xsl:call-template>
  </td>

outputs something like

<td>20开发者_如何学Python11-01-18T07:27:24-00:00</td><td>18,  2011</td>

The second cell doesn't contain name of month (MMM in pattern)

At the same time code below works fine

 <td>
    <xsl:call-template name="date:format-date">
      <xsl:with-param name = "date-time"  select ="hml:LT" />
      <xsl:with-param name = "pattern"   select = "'dd, MMM yyyy'" />
    </xsl:call-template>
  </td>

i.e. without date:add call before I get right date in output:

<td>18, Jan 2011</td>

Is it defect in EXSLT? Or I do something wrong?

I use EXSLT extensions to XSLT and all necessary templates are imported.

Here are full text of test files: XSLT:

 <?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:date="http://exslt.org/dates-and-times" 
    xmlns:hml="http://schemas.test/hml"
    extension-element-prefixes="date"
    exclude-result-prefixes = "hml"
    >

<xsl:import href="date.add.template.xsl" />
<xsl:import href="date.format-date.template.xsl" />
<xsl:import href="str.padding.template.xsl" />


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

 <xsl:template match="/">
    <td>
    <xsl:call-template name="date:add">
      <xsl:with-param name = "date-time"  select ="hml:LT" />
      <xsl:with-param name = "duration"   select = "'PT1H'" />
    </xsl:call-template>
  </td>
  <td>
    <xsl:call-template name="date:format-date">
      <xsl:with-param name = "date-time"  select ="hml:LT" />
      <xsl:with-param name = "pattern"   select = "'dd, MMM yyyy'" />
    </xsl:call-template>
  </td>
  </xsl:template>
</xsl:stylesheet>

and XML:

<hml:LT xmlns:hml="http://schemas.test/hml">2011-01-19T02:16:06-00:00</hml:LT>


I tested your samples with Saxon 6.5.5 and xsltproc on Windows and the output both times is as follows:

<td>2011-01-19T03:16:06-00:00</td><td>19, Jan 2011</td>

So I don't think there is a problem with the templates for the EXSLT functions I took from http://www.exslt.org/, it looks more like a Xalan bug if you don't get the correct output with some version of Xalan.

0

精彩评论

暂无评论...
验证码 换一张
取 消