Re: [xml] xmlwriter and namespaces

On Thu, Jun 07, 2007 at 05:57:45AM -0400, Rob Richards wrote:
Attatched is a patch for xmlwriter to prevent the creation of malformed 
documents due to the allowance of the same namespace declaration being 
output multiple times on an element start tag. For example:

xmlTextWriterStartElementNS(ptr, "foo", "baz", "urn::bar");
xmlTextWriterWriteAttributeNS(ptr, "foo", "abc", "urn::bar", "content");
xmlTextWriterWriteAttributeNS(ptr, "foo", "def", "urn::bar", "content");

Ends up creating:
<foo:baz xmlns:foo="urn::bar" foo:abc="content" xmlns:foo="urn::bar" 
foo:def="content" xmlns:foo="urn::bar"> . . .

rather than:
<foo:baz foo:abc="content" foo:def="content" xmlns:foo="urn::bar">

  okay, make sense.

For performance reasons, unlike .NET, this change only tracks the 
namespace on the starting element tag rather than within the entire 
scope of the element the namespace was declared on.

  Fine, the problem is only serious when it's on the same element.
Propagation of the set of namespace in scope would allow the check
in the subtree in a relatively cheap way though (a bit similar to
what SAX2 parser does).

  Just double check indentation before commiting it was looking a bit
weird in the patch, but that could be an effect of the patch.


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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