Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Date and Time (7/7) >

Days, months, and years from durations

XSLT

      <xsl:stylesheet
                  xmlns:sch="http://www.w3.org/2001/XMLSchema"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0"
                  exclude-result-prefixes=" sch">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <xsl:variable  name="xxx"
                              select="current-date() - '0001-01-01' cast as sch:date"/>
                  <val>
                        <xsl:value-of  select="$xxx"/>
                  </val>
                  <years>
                        <xsl:value-of  select="years-from-duration($xxx cast as sch:dayTimeDuration)"/>
                  </years>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa/>
Output

Error:


error - XPST0051
XPath syntax error at char C on line L in {...x cast as sch:dayTimeDurati...}: Unknown atomic type sch:dayTimeDuration


Failed to compile stylesheet. 1 error detected.


Previous chapter: Recursions
Next chapter: Comments and processing instructions
Previous page: Subtracting dates
Next page: - - -