anchor.diff:  	Events ->
   	    Events
       end.
  +
  +close_collector(Pid) ->
  +    Pid ! {close, self()},
  +    receive
  +	closed ->
  +	    closed
  +    end.
  +
  +parser_loop(TestData) ->
  +		parser_loop(infinity, [], TestData).
  +
  +parser_loop(MaxSize, Options, TestData) ->
  +    CollectorPid = spawn_link(fun() -> receiver([]) end),
  +    parser_loop_int(TestData, fxml_stream:new(CollectorPid, MaxSize, Options), CollectorPid).
  +
  +parser_loop_int([reset | Tail], Handle, CollectorPid) ->
  +    parser_loop_int(Tail, fxml_stream:reset(Handle), CollectorPid);
  +parser_loop_int([{Input, Output} | Tail], Handle, CollectorPid) ->
  +    NHandle = fxml_stream:parse(Handle, Input),
  +    ?assertEqual(Output, collect_events(CollectorPid)),
  +    parser_loop_int(Tail, NHandle, CollectorPid);
  +parser_loop_int([], Handle, CollectorPid) ->
  +    close(Handle),
  +    close_collector(CollectorPid).
   
   stream_test() ->
       CallbackPid = spawn_link(fun() -> receiver([]) end),
  
positive.code: 	    receiver([Msg|Acc]);
  	{get, Parent} ->
  	    Parent ! lists:reverse(Acc),
  	    receiver([])
      end.
  
  collect_events(Pid) ->
  
negative.code:     Stream1 = fxml_stream:parse(Stream0, Data),
      close(Stream1),
      ?assertMatch([{xmlstreamerror, _}], collect_events(CallbackPid)).
  
  element_to_binary_entities_test() ->
      S = <<"<a b='a&#x9;&#xA;&#xD;&lt;>&amp;&quot;&apos;b'>a&lt;&gt;&amp;&quot;&apos;b</a>">>,
      E = #xmlel{name = <<"a">>,
  	       attrs = [{<<"b">>, <<"a\t\n\r<>&\"'b">>}],
  	       children = [{xmlcdata, <<"a<>&\"'b">>}]},
      R = fxml:element_to_binary(E),
      ?assertEqual(S, R),
      ?assertEqual(E, fxml_stream:parse_element(R)).
  
  element_to_binary_resize_test() ->
      A = #xmlel{
  	   name = <<"a">>,
  	   children = [{xmlcdata, <<"1234567890123456790123456789012345678901234567890">>}]
  	  },
  
      ?assertEqual(
         <<"<t>",
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "<a>1234567890123456790123456789012345678901234567890</a>"
  	 "</t>"
         >>,
         fxml:element_to_binary(
  	 #xmlel{name = <<"t">>,
  		children = [A, A, A, A, A,
  			    A, A, A, A, A,
  			    A, A, A, A, A,
  			    A, A, A, A, A]
  	       })).
  
  element_to_binary_test() ->
      ?assertEqual(
  