anchor.diff:                        Tags = dict:fetch(H, RecNames),
   		      OtherResults = dict:fetch(H, ResNames) -- [Result],
   		      true = lists:member(Tag, Tags),
  -		      false = lists:member(Result, OtherResults),
  -                      XMLNSAttrs = if IgnoreXMLNS or HasXMLNSAttr or is_list(XMLNS) ->
  +		      IsDuplicated = lists:member(Result, OtherResults),
  +		      AlreadySeen = lists:member(Result, Seen),
  +                      XMLNSAttrs = if IgnoreXMLNS or HasXMLNSAttr
  +				      or is_list(XMLNS) or IsDuplicated ->
                                              erl_syntax:list([]);
                                         true ->
                                              erl_syntax:list(
  
positive.code:                                                 [abstract(<<"xmlns">>),
                                                   abstract(XMLNS)])])
                                     end,
                        [erl_syntax:clause(
                           [erl_syntax:match_expr(NewResult, Var)],
                           none,
                           [make_function_call(
                              make_enc_fun_name([Tag]),
                              [Var, XMLNSAttrs])])]
                    catch _:_ ->
                            []
                    end
            end, lists:reverse(TaggedSpecs)),
      XmlElClause = erl_syntax:clause(
  		    [erl_syntax:match_expr(
  		       erl_syntax:tuple(
  
negative.code: 			  {RecAcc, ResAcc}
  		  end
  	  end, {dict:new(), dict:new()}, TaggedSpecs),
      NilNSClause = erl_syntax:clause(
  		    [erl_syntax:underscore()], none, [abstract(<<"">>)]),
      {EncClauses, NSClauses, _} =
          lists:foldl(
            fun({Tag, #elem{name = Name, xmlns = XMLNS,
  			  result = Result, attrs = Attrs}},
  	      {EncAcc, NSAcc, Seen}) ->
                    NewResult = labels_to_underscores(Result),
                    Var = label_to_var(prepare_label(undefined, Name)),
  		  HasXMLNSAttr = lists:any(
  