0

以下代码

<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>

输出类似

<td>2011-01-18T07:27:24-00:00</td><td>18,  2011</td>

第二个单元格不包含月份名称(模式中的 MMM)

同时下面的代码工作正常

 <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>

即没有日期:在我得到正确的输出日期之前添加调用:

<td>18, Jan 2011</td>

EXSLT 有缺陷吗?还是我做错了什么?

我使用 XSLT 的 EXSLT 扩展并导入所有必要的模板。

以下是测试文件的全文: 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>

和 XML:

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

1 回答 1

0

我在 Windows 上使用 Saxon 6.5.5 和 xsltproc 测试了您的样本,两次输出如下:

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

因此,我认为我从http://www.exslt.org/获取的 EXSLT 函数的模板没有问题,如果您没有获得某些版本的正确输出,它看起来更像是 Xalan 错误夏兰。

于 2011-01-19T12:48:05.590 回答