Search code examples
xsltsaxonxpath-2.0stylevision

Cast failed, invalid lexical value - xs:dateTime


I am trying to convert a string to date in Altova StyleVision using an Xpath Expression but I am getting this error.

Error in XPath 2.0 expression
Line 358, Character 32


(Cast failed, invalid lexical value - xs:dateTime '2017-16-09T12:16:59.407+03:00')

My expression is below.

format-dateTime(xs:dateTime('2017-16-09T12:16:59.407+03:00'), '[Y0001]/[M01]/[D01]')

Any help will be highly appreciated.


Solution

  • It's an unhelpful error message. Saxon does better:

    Error on line 1 column 29 of file:/Users/mike/Desktop/temp/:
      FORG0001: Invalid dateTime value "2017-16-09T12:16:59.407+03:00" (Month is out of range)
    

    The problem is that there is no month 16.