anchor.diff:  'sum'(Ctx,Arg1) ->
      'sum'(Ctx,Arg1,?atint(0)).
   
  -'sum'(_Ctx,Arg1,Arg2) -> 
  -   case ?seq:is_empty(Arg1) of
  -      true ->
  -         Arg2;
  -      _ ->
  -         {Seq,SeqType} = compare_convert_seq(?seq:to_list(Arg1), [], []),
  -         %?dbg("sum", {Seq,SeqType}),
  -         if ?numeric(SeqType) ->
  +'sum'(_,[],Arg2) -> Arg2;
  +'sum'(_,Arg1,_) -> 
  +   {Seq,SeqType} = compare_convert_seq(?seq:to_list(Arg1), [], []),
  +   if ?numeric(SeqType) ->
  +         Sum1 = sum1(lists:reverse(Seq), []),
  +         xqerl_types:cast_as(Sum1, SeqType);
  +      true ->
  +         case xqerl_types:is_date_type(SeqType) of
  +            true ->
                  Sum1 = sum1(lists:reverse(Seq), []),
                  xqerl_types:cast_as(Sum1, SeqType);
  -            true ->
  -               case xqerl_types:is_date_type(SeqType) of
  -                  true ->
  -                     Sum1 = sum1(lists:reverse(Seq), []),
  -                     xqerl_types:cast_as(Sum1, SeqType);
  -                  _ ->
  -                     ?err('FORG0006')
  -               end
  +            _ ->
  +               ?err('FORG0006')
            end
      end.
   
  
positive.code:          ?atm('xs:anyURI',Uri)
     end.
  
  %% Returns the namespace URI of one of the in-scope namespaces for $element, identified by its namespace prefix. 
  'namespace-uri-for-prefix'(Ctx,Prefix,[Element]) ->
     'namespace-uri-for-prefix'(Ctx,Prefix,Element);
  'namespace-uri-for-prefix'(_Ctx,Prefix,#xqNode{doc = {doc,File}, node = Node}) -> 
     Doc = ?get({doc,File}),
     'namespace-uri-for-prefix'(_Ctx,Prefix,#xqNode{doc = Doc, node = Node});
  'namespace-uri-for-prefix'(_Ctx,Prefix,#xqNode{doc = Doc, node = Node}) -> 
  
negative.code:       [S,_] ->
           ?str(S)
     end.
  
  %% Returns a value obtained by adding together the values in $arg. 
  'sum'(_Ctx,[]) ->
  