tags:

views:

303

answers:

2

XSLTProcessor::hasExsltSupport() returns true. Now what do I have to modify so I can use it?

I have

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

Transformation what I'm trying to do:

 <td>
   <xsl:value-of select="date:format-date(translate(property[@name='changedate']/value, ' ', 'T'), 'd.m.y h:i')" />
 </td>
  • property[@name='changedate']/value is stamp from SQL DB (yyyy-mm-dd hh:mm:ss)
  • First replace that space to T so that exslt date-format understands it
  • Change yyyy-mm-ddT*hh:mm:ss* -> dd.mm.yyyy hh:mm

Error:

Warning: XSLTProcessor::transformToXml() [xsltprocessor.transformtoxml]: xmlXPathCompOpEval: function date bound to undefined prefix format

PHP version 5.2.9

  • XSL enabled
  • libxslt Version 1.1.24
  • libxslt compiled against libxml Version 2.6.32
  • EXSLT enabled
  • libexslt Version 1.1.24
A: 

"The following extension functions are not considered stable and are not part of the core of EXSLT - Dates and Times. Processors that claim support of EXSLT - Dates and Times might not support these functions." - this applies to format-date as well.

Pavel Minaev
format-date(): http://exslt.org/date/functions/format-date/index.html
raspi
Yup, missed it. See the edit.
Pavel Minaev
A: 

I fixed it with this. It moves date information to correct positions.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  <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>
raspi