xmerl_sax_parser:stream/2 doesn't know when to stop

Per Melin per.melin@REDACTED
Fri Nov 5 20:27:52 CET 2010


(I've only tested with R13B04 but there is nothing in the release
notes that indicates that this would be different in R14B.)

Without the continuation_fun option xmerl_sax_parser:stream/2 works as
I would expect. But with a continuation_fun it needs to be fed at
least one extra character after a complete document.

1> EventFun = fun(E, _, S) -> erlang:display(E), S end.
#Fun<erl_eval.18.105910772>
2> ContFun = fun(S) -> {io:get_line(">> "), S} end.
#Fun<erl_eval.6.13229925>
3> xmerl_sax_parser:stream("<foo />", [{event_fun, EventFun},
{continuation_fun, ContFun}]).
startDocument
{startElement,[],"foo",{[],"foo"},[]}
{endElement,[],"foo",{[],"foo"}}
>>

Here it has called ContFun and is waiting for additional input. It
will accept anything that is not whitespace, and then return it as a
rest. Let's give it an "x".

>> x
endDocument
{ok,undefined,"x\n"}
4>

It seems this used to be a problem even without continuation_fun, but
the patch described here painted over it:
http://www.erlang.org/cgi-bin/ezmlm-cgi/4/46754


More information about the erlang-bugs mailing list