Need the same XQ function in multiple responses?
Define it in the script library in the local namespace and use it in any XQ-capable input field:
declare function
local:formatOfficeId($s as xs:string?)
as xs:string? {
if( string-length($s) = 6 )
then (
concat('0000',$s)
) else if( string-length($s) = 7 )
then (
concat('000',$s)
) else if( string-length($s) = 8 )
then (
concat('00',$s)
) else (
concat('00000',$s)
)
};
and then in the response:
...
<office-id>{local:formatOfficeId($input//*:oid)}</office-id>
...