1

XSLTProcessor::hasExsltSupport() 返回真。现在我必须修改什么才能使用它?

我有

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

转换我正在尝试做的事情:

 <td>
   <xsl:value-of select="date:format-date(translate(property[@name='changedate']/value, ' ', 'T'), 'd.m.y h:i')" />
 </td>
  • property[@name='changedate']/value 是来自 SQL DB 的标记 (yyyy-mm-dd hh:mm:ss)
  • 首先将该空间替换为 T 以便exslt 日期格式理解它
  • 更改 *yyyy-mm-dd***T***hh:mm:ss* -> dd.mm.yyyy hh:mm

错误:

警告:XSLTProcessor::transformToXml() [xsltprocessor.transformtoxml]: xmlXPathCompOpEval: 函数日期绑定到未定义的前缀格式

PHP 版本 5.2.9

  • 启用 XSL
  • libxslt 版本 1.1.24
  • 针对 libxml 版本 2.6.32 编译的 libxslt
  • 启用 EXSLT
  • libexslt 版本 1.1.24
4

2 回答 2

1

我用这个修复了它。它将日期信息移动到正确的位置。

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template name="FormatDate">
    <xsl:param name="DateTime" />

    <xsl:variable name="mo">
      <xsl:value-of select="substring($DateTime, 6, 2)" />
    </xsl:variable>

    <xsl:variable name="day">
      <xsl:value-of select="substring($DateTime, 9, 2)" />
    </xsl:variable>

    <xsl:variable name="year">
      <xsl:value-of select="substring($DateTime, 1, 4)" />
    </xsl:variable>

    <xsl:variable name="time">
      <xsl:value-of select="substring($DateTime, 12, 8)" />
    </xsl:variable>

    <xsl:variable name="hh">
      <xsl:value-of select="substring($time, 1, 2)" />
    </xsl:variable>

    <xsl:variable name="mm">
      <xsl:value-of select="substring($time, 4, 2)" />
    </xsl:variable>

    <xsl:value-of select="$day" />
    <xsl:value-of select="'.'" />
    <xsl:value-of select="$mo" />
    <xsl:value-of select="'.'" />
    <xsl:value-of select="$year" />

    <xsl:value-of select="' '" />

    <xsl:value-of select="$hh" />
    <xsl:value-of select="':'" />
    <xsl:value-of select="$mm" />

  </xsl:template>
</xsl:stylesheet>
于 2009-09-05T18:04:32.133 回答
0

“以下扩展功能不被认为是稳定的,并且不是 EXSLT - Dates and Times 核心的一部分。声称支持 EXSLT - Dates and Times 的处理器可能不支持这些功能。” - 这也适用format-date

于 2009-09-05T11:09:03.567 回答