@@ -273,6 +273,44 @@ const BUILT_IN_FUNCTIONS: Record<string, (context: XPathContext, ...args: any[])
273273 'analyze-string' : STR30 . analyzeString ,
274274 'format-integer' : STR30 . formatInteger ,
275275 'format-number' : STR30 . formatNumber ,
276+
277+ // XPath 2.0 Type Constructor Functions (xs:* namespace)
278+ // These wrap the type system's castAs functionality for function references
279+ 'xs:string' : ( _ctx , arg ) => castAs ( arg , 'string' ) ,
280+ 'xs:boolean' : ( _ctx , arg ) => castAs ( arg , 'boolean' ) ,
281+ 'xs:decimal' : ( _ctx , arg ) => castAs ( arg , 'decimal' ) ,
282+ 'xs:float' : ( _ctx , arg ) => castAs ( arg , 'float' ) ,
283+ 'xs:double' : ( _ctx , arg ) => castAs ( arg , 'double' ) ,
284+ 'xs:integer' : ( _ctx , arg ) => castAs ( arg , 'integer' ) ,
285+ 'xs:duration' : ( _ctx , arg ) => castAs ( arg , 'duration' ) ,
286+ 'xs:dateTime' : ( _ctx , arg ) => castAs ( arg , 'dateTime' ) ,
287+ 'xs:date' : ( _ctx , arg ) => castAs ( arg , 'date' ) ,
288+ 'xs:time' : ( _ctx , arg ) => castAs ( arg , 'time' ) ,
289+ 'xs:anyURI' : ( _ctx , arg ) => castAs ( arg , 'anyURI' ) ,
290+ 'xs:QName' : ( _ctx , arg ) => castAs ( arg , 'QName' ) ,
291+ 'xs:untypedAtomic' : ( _ctx , arg ) => castAs ( arg , 'untypedAtomic' ) ,
292+ // Gregorian types
293+ 'xs:gYearMonth' : ( _ctx , arg ) => castAs ( arg , 'gYearMonth' ) ,
294+ 'xs:gYear' : ( _ctx , arg ) => castAs ( arg , 'gYear' ) ,
295+ 'xs:gMonthDay' : ( _ctx , arg ) => castAs ( arg , 'gMonthDay' ) ,
296+ 'xs:gDay' : ( _ctx , arg ) => castAs ( arg , 'gDay' ) ,
297+ 'xs:gMonth' : ( _ctx , arg ) => castAs ( arg , 'gMonth' ) ,
298+ // Binary types
299+ 'xs:hexBinary' : ( _ctx , arg ) => castAs ( arg , 'hexBinary' ) ,
300+ 'xs:base64Binary' : ( _ctx , arg ) => castAs ( arg , 'base64Binary' ) ,
301+ // Integer-derived types
302+ 'xs:long' : ( _ctx , arg ) => castAs ( arg , 'long' ) ,
303+ 'xs:int' : ( _ctx , arg ) => castAs ( arg , 'int' ) ,
304+ 'xs:short' : ( _ctx , arg ) => castAs ( arg , 'short' ) ,
305+ 'xs:byte' : ( _ctx , arg ) => castAs ( arg , 'byte' ) ,
306+ 'xs:nonPositiveInteger' : ( _ctx , arg ) => castAs ( arg , 'nonPositiveInteger' ) ,
307+ 'xs:negativeInteger' : ( _ctx , arg ) => castAs ( arg , 'negativeInteger' ) ,
308+ 'xs:nonNegativeInteger' : ( _ctx , arg ) => castAs ( arg , 'nonNegativeInteger' ) ,
309+ 'xs:positiveInteger' : ( _ctx , arg ) => castAs ( arg , 'positiveInteger' ) ,
310+ 'xs:unsignedLong' : ( _ctx , arg ) => castAs ( arg , 'unsignedLong' ) ,
311+ 'xs:unsignedInt' : ( _ctx , arg ) => castAs ( arg , 'unsignedInt' ) ,
312+ 'xs:unsignedShort' : ( _ctx , arg ) => castAs ( arg , 'unsignedShort' ) ,
313+ 'xs:unsignedByte' : ( _ctx , arg ) => castAs ( arg , 'unsignedByte' ) ,
276314} ;
277315
278316/**
@@ -371,6 +409,40 @@ const FUNCTION_ARITY: Record<string, [number, number]> = {
371409 'analyze-string' : [ 2 , 3 ] ,
372410 'format-integer' : [ 2 , 3 ] ,
373411 'format-number' : [ 2 , 3 ] ,
412+
413+ // XPath 2.0 Type Constructor Functions (xs:* namespace)
414+ 'xs:string' : [ 1 , 1 ] ,
415+ 'xs:boolean' : [ 1 , 1 ] ,
416+ 'xs:decimal' : [ 1 , 1 ] ,
417+ 'xs:float' : [ 1 , 1 ] ,
418+ 'xs:double' : [ 1 , 1 ] ,
419+ 'xs:integer' : [ 1 , 1 ] ,
420+ 'xs:duration' : [ 1 , 1 ] ,
421+ 'xs:dateTime' : [ 1 , 1 ] ,
422+ 'xs:date' : [ 1 , 1 ] ,
423+ 'xs:time' : [ 1 , 1 ] ,
424+ 'xs:anyURI' : [ 1 , 1 ] ,
425+ 'xs:QName' : [ 1 , 1 ] ,
426+ 'xs:untypedAtomic' : [ 1 , 1 ] ,
427+ 'xs:gYearMonth' : [ 1 , 1 ] ,
428+ 'xs:gYear' : [ 1 , 1 ] ,
429+ 'xs:gMonthDay' : [ 1 , 1 ] ,
430+ 'xs:gDay' : [ 1 , 1 ] ,
431+ 'xs:gMonth' : [ 1 , 1 ] ,
432+ 'xs:hexBinary' : [ 1 , 1 ] ,
433+ 'xs:base64Binary' : [ 1 , 1 ] ,
434+ 'xs:long' : [ 1 , 1 ] ,
435+ 'xs:int' : [ 1 , 1 ] ,
436+ 'xs:short' : [ 1 , 1 ] ,
437+ 'xs:byte' : [ 1 , 1 ] ,
438+ 'xs:nonPositiveInteger' : [ 1 , 1 ] ,
439+ 'xs:negativeInteger' : [ 1 , 1 ] ,
440+ 'xs:nonNegativeInteger' : [ 1 , 1 ] ,
441+ 'xs:positiveInteger' : [ 1 , 1 ] ,
442+ 'xs:unsignedLong' : [ 1 , 1 ] ,
443+ 'xs:unsignedInt' : [ 1 , 1 ] ,
444+ 'xs:unsignedShort' : [ 1 , 1 ] ,
445+ 'xs:unsignedByte' : [ 1 , 1 ] ,
374446} ;
375447
376448/**
0 commit comments