[jdev] parsing xml (xmpp) with ruby
Justin Karneges
justin-keyword-jabber.093179 at affinix.com
Mon Sep 29 01:42:56 CDT 2008
On Sunday 28 September 2008 21:52:49 jlist wrote:
> In the case of a TLS connection, there's also the switch
> from plain text to TLS...
>
> I'm also coming to think that the best (or easiest) way
> could be to use a SAX parser to parse out the stanzas, then
> use a DOM parser for easy access to the attributes. However,
> this may not handle the TLS's case though. I haven't looked
> into the details but I suspect I need to handcraft the SAX
> parser for the <stream> tags just to handle this scenario.
There's two issues with switching on TLS:
1) Parse a new <stream>. This is super easy. As soon as you get the
<proceed/> tag, just throw away your old SAX parser instance and create a new
one. Done.
2) Don't send TLS bytes into your SAX parser. When you receive
<proceed/>[binary data], then you want to make sure that [binary data] isn't
SAX-parsed. Unless your parser allows you to peek at unprocessed data, the
purest solution is to feed one byte at a time to the parser so that you can
manage an "unprocessed" data buffer yourself.
Despite that the #2 problem is not very enjoyable, neither of these issues
should require a hand-crafted SAX parser to solve.
-Justin
More information about the JDev
mailing list