<div>I have a version of erlsom that works on binaries. I made it because I thought it would be faster, but it turned out that this was not the case. I guess that this will change with release 12, and I am planning to revive it.
<div>The current version works only on UTF-8 encoded binaries. I remember that I hadn't quite figured out how I could make a version for UTF-16 without copying the entire SAX parser (and slightly modifiying it in many places, obviously). Actually, one for UTF-16 be and one for le. Not that that would be such a big issue, but it is just not very nice.
<div>Why do you want a parser that works on binaries?</div>
<div><span class="gmail_quote">On 11/23/07, <b class="gmail_sendername">Ulf Wiger (TN/EAB)</b> <<a href="mailto:firstname.lastname@example.org">email@example.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Joel Reymont skrev:<br>> Has anyone extracted the expat driver code from ejabberd?<br>><br>> Is there another XML parser that works on binaries?
<br>><br>> Would hacking XMERL to work on binaries be a good idea?<br>><br>> Thanks, Joel<br><br>Yes and no. The Xmerl parser is not easily hacked to work<br>on binaries, and I think it would be a waste of time to
<br>do so. It would require touching most of the code.<br><br>The right approach would be to redesign it with a proper<br>tokenizer. It would then be fairly easy to either support<br>two different tokenizers, or one that supports both string
<br>and binary input.<br><br>Of course, this would mean a complete redesign of xmerl_scan,<br>but that would have its advantages. I think the API can be kept<br>and improved upon (e.g. offering a lightweight parser API<br>
that uses the same tokenizer and parser.)<br><br>The quick way to do this would be e.g. to buy Joe a beer<br>and convince him to share his xml parser code. Neither<br>xmerl nor erlsom use a tokenizer approach, and having looked
<br>at Joe's stuff, I'm convinced that's the way to go.<br><br>Meanwhile, xmerl_eventp.erl can be used to see how an xmerl<br>wrapper can deal with binaries and hook into xmerl_scan.<br>The trick is to use the xmerl 'fetch' hook, which is called
<br>each time xmerl needs more data. The fetch function needs to<br>buffer input until it finds some whitespace - see<br>xmerl_eventp:find_good_split/6. This has to do with entity<br>expansion, if I recall correctly, so if you don't have that
<br>in your XML, it shouldn't matter... (don't take my word for<br>it, though. It's been a few years since I last dabbled with it.)<br><br>BR,<br>Ulf W<br>_______________________________________________<br>erlang-questions mailing list
<br><a href="mailto:firstname.lastname@example.org">email@example.com</a><br><a href="http://www.erlang.org/mailman/listinfo/erlang-questions">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote>