[Expat-discuss] use of expat with socket

Fred L. Drake, Jr. fdrake@acm.org
Wed, 25 Jul 2001 09:48:11 -0400 (EDT)


Thomas J. Clancy writes:
 > Yes, I agree with this.  But it would be nice to have a handler that
 > notified you when the end of the xml document had been reached (i.e. the
 > close tag of the main document element) so that you could take it from there

  There already *is* an end-element event, and all that's needed from
there is a counter so you know when the document element is complete.

 > and come back when you want more, perhaps resetting some flag in the parser
 > so that it would continue from the point in the buffer where you left off as
 > if it were starting anew.  The fact that the parser knew there was junk
 > after the closing document element leads me to believe that the parser knew
 > when it had reached the end of the document.

  It knows when it reaches the end of the document element, but
there's a specific requirement that nothing follows that.  If there
is, even a non-validating parser is required to report an error.  It
knows it's reached the end of the document because that's when you
stop feeding it data.  In all carefully engineered systems, it is the
responsibility of the container to determine where the end of the
contained object is; the contained object cannot be assumed to know
enough about the container to read itself from the container's
stream.

 > But  I do like the idea of embedding the XML into another protocol, and MIME
 > seems to be a particularly nice way in which to wrap this.

  Yes, indeed!

 > Thanks for your input.  It was most helpful.




  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Digital Creations