XSLT Error Reference

FORG0001

XSLT 2.0+ function error
Error message
Invalid value for cast/constructor: xs:integer("abc")

A cast or constructor function received a value it cannot convert — casting text to a number or date is the usual suspect. Guard with 'castable as' or use number().

What it means

A constructor like xs:integer(...), xs:date(...) or an implicit cast received a lexical value that is not valid for the target type: xs:integer('abc'), xs:date('2026-13-45'), or an empty string.

Common causes

  1. Dirty or empty data — casting @qty when some elements have qty="".
  2. Format mismatchxs:date('02/07/2026'): XSD dates must be 2026-07-02.
  3. Locale-style numbersxs:decimal('1.234,56') fails; XSD uses . as decimal separator only.

How to fix it

  • Guard the cast:
<xsl:value-of select="if (@qty castable as xs:integer)
                      then xs:integer(@qty) else 0"/>
  • Or use number() when NaN is acceptable: number('abc') returns NaN instead of raising an error — handy for optional numeric fields.
  • Normalize the lexical form first (translate(), replace(), format-date patterns) before casting dates and decimals.