[xquery-talk] Masks in xquery

Ghislain Fourny gfourny at inf.ethz.ch
Wed Mar 23 11:18:54 PST 2011


Hi Julio,

I am not aware of a built-in function for this, but could the following be what you are looking for? (It is very simplified, you might need to add error-handling)


declare function local:mask($number, $size)
{
  let $string := xs:string($number)
  let $length := string-length($string)
  return concat(
    string-join(for $i in 1 to $size - $length return "0", ""),
    $string)
};

local:mask(1000, 10)


Kind regards,
Ghislain


> Hi *,
>  
> I have a node whose value goes from 1 to 1000 and I have to represent it with a mask of 10 digits. For example: 0000000001 or 0000001000. Is there any function to do this kind of operation?
>  
> Thanks in advance
>  
> Regards
>  
> Julio





More information about the talk mailing list