anchor.diff:      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(
  
positive.code:        collect_events(CallbackPid)).
  
  stream_reset_test() ->
      CallbackPid = spawn_link(fun() -> receiver([]) end),
      S0 = new(CallbackPid),
      S1 = fxml_stream:parse(S0, <<"<a xmlns='ns1'><b/>">>),
      S2 = fxml_stream:reset(S1),
      S3 = fxml_stream:parse(S2, <<"<a><b/></a>">>),
      close(S3),
      ?assertEqual(
         [{xmlstreamstart, <<"a">>, [{<<"xmlns">>, <<"ns1">>}]},
  	{xmlstreamelement, #xmlel{name = <<"b">>}},
          {xmlstreamstart, <<"a">>, []},
  	{xmlstreamelement, #xmlel{name = <<"b">>}},
  	{xmlstreamend, <<"a">>}],
         collect_events(CallbackPid)).
  stream_error_test() ->
      CallbackPid = spawn_link(fun() -> receiver([]) end),
      S0 = new(CallbackPid),
  
negative.code: 	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),
  