Need to convert a text value `2012-03-19′ into a date type, then extract the year component.
<xsl:variable name="dateValue" select="2012-03-19"/>
<xsl:variable name="year" select="year-from-date(date($dateValue))"/>
I’m using Saxon 2.0, but it’s complaining date function does not exist; I looked around Saxon’s documentation and could not find the function, so that’s clearly the issue, but I can’t find a suitable replacement.
I don’t think
date()should be a function, you want thexs:date()data type.Add the
xsnamespace and then prefixxs:date().The following stylesheet, using any well-formed XML input, will produce
2012:Note that you also have to quote your
selectin your “dateValue”xsl:variable.