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



On Tue, Aug 12, 2003 at 11:05:50AM -0400, Daniel Veillard wrote:

[ snip ]

(the above all sounds good)

      Alternatively I'm thinking about splitting namespace and attribute 
      callbacks, so that more information known by the parser can be passed 
      up to the client code, in that case atts and attsNs in startElementNs
      disapears and 2 new callback type are provided and called just after the
      startElement
      void namespace(
                 void *ctx,
               const xmlChar *prefix,
               const xmlChar *URL
               )
      void attributeNs(
                 void *ctx,
               const xmlChar *localname, //local attribute name
               const xmlChar *prefix,
               const xmlChar *URL,
               const xmlChar *value,
               )
      there is one thing to note, that a namespace() callback may actually
      provide the namepace binding for the element after startElementNs()
      was called like in <foo:bar xmlns:foo="bar"/>

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?

In my particular application I can work round this.

      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.

cheers,

Graham.

-- 
Graham Bennett



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