Re: [xml] Problem in Default Namespace handling defined in DTD



On Mon, Feb 25, 2008 at 06:32:53PM +0530, Ashwin wrote:

   Hi ,

   For the xml file attached the corresponding DTD contains the namespace
   declaration  as a default attribute of the element svg. However when I
   parse the xml file using Sax Api's for the second svg element I do not
   get  the  default nspace as part of the start element Ns callback, for
   the  firstvelement  I get nspace attribute....On debugging I found the
   problem  occurred  when  the namespace has been pushed on the stack if
   the name space occurs a second time the namespace attribute counter is
   updated,  maybe  this  is  the  expected  behaviour, if so there is no
   problem,  however if it is not so then the namespace attribute counter
   nbNs  needs  to  be  incremented.  I  am  attaching  the patch for the
   problem.

  I think it's the expected behaviour, you know the namespace exists at that
point it's correctly in scope, it will be attributed properly, but the point
of having defaulting from the DTD is to avoid pollution on nodes in the 
serialization. Libxml2 ensures that the namesapce are properly issued 
in the tree if saved back but prevent from having that on every single node
which is really unnecessary. Doing what you suggest would raise an awful
lot of complaints from people because their documents would suddenly 
get namespaces declaration added on all elements instead of the root element
(or the top element of the subtree where the namespace is in effect).
  Also incrementing nbNs without having pushed the associated data on the
stack looks a fairly sure case of data corruption coming up if you 
pop up the given elements, i'm 99% sure it's a potential crasher.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
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]