Re: [xml] Refactoring of the SAX interface for namespace support.



On Wed, Aug 13, 2003 at 10:19:46PM +0100, Graham Bennett wrote:
I like the idea of exposing more of the parser's data this way.  The
only thing that I don't like is that there doesn't seem to be any clear
separation between the end of the information for the start of the
element and the start of the content.

So if I get the following sequence of events:

startElementNS
namespace
namespace
attributeNS
attributeNS
-----------------
startElementNS
endElementNS
-----------------
endElementNS

Then I only know that I have all the information for the start of the
element once I get the next element callback.  The callback that tells
me this could equally well be a comment, text or processing instruction,
or am I missing something?

  Yup that's right, but following the exchange with Dave Beckett
we need to provide the namespaces as part of the startElementNS
callback. I simply suggest to also add the number of attributes
to come:
         StartElementNs(
              void *ctx,
              const xmlChar *localname;
              const xmlChar *prefix,
              const xmlChar *URI
              int nb_namespaces,          // number of namespace definitions
              const xmlChar **namespaces, // namespaces (prefix/URI pairs)
              int nb_attributes
              )

  that's something Dave also asked for. The order of the attributes also 
doesn't matter,

      there is another option even more disturbing from an API viewpoint:
        change name to simple const xmlChar * zero terminated to
    const xmlChar * with a lenght in bytes, like for the character
    callbacks.
      goal would be to minimize the number of string copies needed, this could
      be very effective for attribute values which operates on a non-bounded
      vocabulary. Minimizing the number of string allocated for tags can
      be done very easilly by the parser since the values pertains to a fixed
      vocabulary this is part of the enhancements I have long planned to do
      in libxml2.

This would be very desirable from my point of view, as in my app I am
always going to copy the string again anyway.

   Well I would limit this to attribute values (well characters() also
 work that way), for small strings it's unclear it's a big gain.

Daniel

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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]