Oh, by the way, don't be scared off by the need to alter the code to fit the 
model. It is really quick to do. My original methodolody used a stream that 
blocks the calling thread on a Read() when there is no more data. 
Unfortunately, it also meant that each client needed two threads (one for 
reading from the network, one for reading the XML) so I had to pull it out.

You can also try and take the route Coversant used, which is waiting for 
complete stanzas before reading from the XML parser, but I have heard that it 
may not scale as well as other methods (but again, it looks like they don't 
really have scalability issues) and it could introduce subtle errors such as:

<node> <[CDATA[ </node> Something ]]> </node>

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Jonathan Dickinson
> Sent: Friday, October 03, 2008 7:49 AM
> To: Jabber/XMPP software development list
> Subject: Re: [jdev] parsing xml (xmpp) with ruby
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> > Behalf Of Eric Will
> > Sent: Thursday, October 02, 2008 6:26 PM
> > To: Jabber/XMPP software development list
> > Subject: Re: [jdev] parsing xml (xmpp) with ruby
> >
> > ... I don't know what a "push
> > parser" is, and Google seems mostly silent on the matter.
> >
>
> A push parser is one of those dark arcane wizardry type things. Most of
> the time it's (incorrectly, IIRC) called a SAX parser. Essentially it
> comes down to a very crucial difference, which I will demonstrate in
> pseudo code.
>
> So our classical XML reader:
> Set stream = create stream that reads from network client
> Set parser = create parser that reads from 'stream'
>
> While 'parser' has more nodes
>   Set node = next node from 'parser'
>   Do something with 'node'
> End while
>
> Our push mode one:
> Set stream = create stream that reads from network client
> Set parser = create parser
>
> Assign parser event called 'Element Started' to method 'My Element
> Started'
>
> While 'stream' has more data (typically threaded or such, but this is
> pseudo-code)
>   Set data = read data from 'stream'
>   Call 'push' method on 'parser' giving it 'data'
> End while
>
> Method 'My Element Started' that takes one Xml Node parameter called
> 'node'
>   Do something with 'node'
> End Method
>
> Hopefully that explains the difference. The parser is optimized so that
> I can efficiently handle incomplete documents, without being under the
> strain of always having to return a node.
>
> >
> > > Stephan
> >
> > -- Eric Will // rakaur --
> > _______________________________________________
> > JDev mailing list
> > FAQ: http://www.jabber.org/discussion-lists/jdev-faq
> > Forum: http://www.jabberforum.org/forumdisplay.php?f=20
> > Info: http://mail.jabber.org/mailman/listinfo/jdev
> > Unsubscribe: [EMAIL PROTECTED]
> > _______________________________________________
> _______________________________________________
> JDev mailing list
> FAQ: http://www.jabber.org/discussion-lists/jdev-faq
> Forum: http://www.jabberforum.org/forumdisplay.php?f=20
> Info: http://mail.jabber.org/mailman/listinfo/jdev
> Unsubscribe: [EMAIL PROTECTED]
> _______________________________________________
_______________________________________________
JDev mailing list
FAQ: http://www.jabber.org/discussion-lists/jdev-faq
Forum: http://www.jabberforum.org/forumdisplay.php?f=20
Info: http://mail.jabber.org/mailman/listinfo/jdev
Unsubscribe: [EMAIL PROTECTED]
_______________________________________________

Reply via email to