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



On Wed, Aug 13, 2003 at 09:43:19AM +0200, Fabrice Desré wrote:
  Hi Daniel,

  My preference goes to the distinct callbacks for elements and attributes.

  I think it's cleaner and more efficient than trying to push too many
arguments in a callback function. The drawback are for things like the python
bindings where the callback is marshalled into an expensive operation,
there would be more operations so the sax badings would be a bit slower.

      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"/>

  Very good idea IMHO. This would make it easier to deal with documents 
that use QNames in content. This callback should also be called to 
notify when the default namespace changes.

  yep for any xmlns declaration found.

      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.

I'm not sure to understand you ont this. Do you mean that the attribute 
callback could report the value of the attribute by chunks ? Or the name 
of the attribute ?

  name of the attribute + the string + len of the string. 
Assuming no normalization or change is needed then the callback could then
operate directly from the memory buffer instead of neededing a string
allocation and duplication for each and every attribute value. A single
callback call per attribute or namespace but different:
    void attributeNs(const xmlChar *name, const xmlChar *value, int vlen,
                     const xmlChar *prefix, const xmlChar *URI);

   typically
     <h href="img.gif"/>
   would lead to 
     attributeNs("href", "img.gif\"/>", 7, NULL, NULL);
assuming no default namespace.

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]