26 Feb
2020
26 Feb
'20
12:42 p.m.
Hi, I want to declare a function that can operate on various elements of a record. It should be possible to pass the element-name as parameter to the function. I tried this: declare function local:cloudWords( $Veld as xs:string ) as xs:string* { let $base := collection('IncidentRemarks/Incidentsv')/csv/record let $txt := string-join( $base/$Veld/text(), " ") let $words := tokenize($txt,'(\s|[,.!:;]|[n][b][s][p][;])+') return ($words) }; let $retValue := local:cloudWords("INC_RM") return $retValue But I get this error: [XPTY0019] text(): node expected, xs:string found: "INC_RM". Should I use xquery:eval to transform "$base/$Veld/text()" into "$base/INC_RM/text()" Ben