dateTime.xsl 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
  5. xmlns:system_cache__dita="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/dita.xsd"
  6. exclude-result-prefixes="xs"
  7. version="2.0">
  8. <xsl:variable name="data" select="'2017-10-10T00:00:00'"/>
  9. <xsl:variable name="data2" select="'01.02.2017'"/>
  10. <xsl:function name="system_cache__dita:year">
  11. <xsl:param name="date"/>
  12. <xsl:choose>
  13. <xsl:when test="string($data) castable as xs:dateTime">
  14. <xsl:message>#20 passed as dateTime</xsl:message>
  15. <xsl:value-of select="format-date(xs:date(xs:dateTime($data)),'[Y]')"/>
  16. </xsl:when>
  17. <xsl:when test="string($data) castable as xs:date">
  18. <xsl:message>#20 passed as date</xsl:message>
  19. <xsl:value-of select="format-date(xs:date($data),'[Y]')"/>
  20. </xsl:when>
  21. <!--<xsl:when test="tokenize(string($date),'\.')[3]">
  22. <xsl:message>#20 passed as tokenize</xsl:message>
  23. <xsl:value-of select="tokenize($date,'\.')[3]"/>
  24. </xsl:when>-->
  25. <xsl:otherwise>
  26. <xsl:message terminate="yes">#28 Error in date format for value <xsl:value-of select="$data"/>! </xsl:message>
  27. </xsl:otherwise>
  28. </xsl:choose>
  29. </xsl:function>
  30. <xsl:template name="main">
  31. <xsl:value-of select="$data"/>=<xsl:value-of select="system_cache__dita:year($data)"/><xsl:text>
  32. </xsl:text>
  33. <xsl:value-of select="$data2"/>=<xsl:value-of select="system_cache__dita:year($data2)"/>
  34. </xsl:template>
  35. </xsl:stylesheet>