[JDEV] just wondering...

Daniel Veillard veillard at redhat.com
Mon Jan 7 15:46:05 CST 2002


On Fri, Jan 04, 2002 at 04:41:39PM -0800, zak wrote:
> for example, instead of sending this...
> 
>  <?xml version='1.0' encoding='UTF-8' ?> <stream:stream to='jabber.org' 
> xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>
> 
> doesn't it make sense to send...
> 
>  <?xml version='1.0' encoding='UTF-8' ?> <stream:stream to='jabber.com' 
> xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>
> </stream:stream>

   there is 2 problems with this, one serious one minor:
     - the serious one is the following:
       Look at the production for an XML document in the spec:
       http://www.w3.org/TR/REC-xml#NT-document
       [1]    document    ::=    prolog element Misc*

       The last term means that the XML document does not terminate with
       the end of the root element. An XML parser has no way of detecting
       the end of the document entity. It must be provided by another
       layer (usually underneath like the end of the file). So either
       you have to hack to detect the end of the root element and
       arbitrary decide that's the end of the document or you have
       to insert markers in the stream. In both case you end up doing
       a preparsing of the input stream or you have to mix layers of
       recognitions. Unfortunately people seems to do that often, trying
       to pile up a contiguous set of XML document on a single flow.

     - the less serious one is that reusing an XML parser state for
       parsing multiple document doesn't make much sense, and is again
       a very common recipe for disasters. So you end up having to 
       recreate or reinitialize a parser state for every messages. Not
       good at all for performances.

  Actually the use of a continuous pair of XML documents for the data
exchange in Jabber was novel for me, I was surprized but it's actually
very smart, it can do this (this really helps performances and simplicity
of implementation) because it keeps the connection. Most other use of XML
in protocol (WebDav, XML-RPC, SOAP on HTTP, etc ...) don't keep the connection
and have to associate 1 or 2 documents per exchange.
  I implemented XML-RPC on top of Jabber (following the draft from last summer)
and it's actually very nice to be able to parse all the XML-RPC calls of the
application with the same parser instance, neat !

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard at redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



More information about the JDev mailing list