[Mono-list] xmlns dupes
Sebastien Pouliot
Sebastien Pouliot <spouliot@videotron.ca>
Thu, 16 Jan 2003 21:13:37 -0500
I'd this problem for quite some time but didn't had (well take) the time to
pinpoint its location.
So here's how to make it fail !
static void Main(string[] args) {
XmlDocument doc = new XmlDocument ();
doc.LoadXml("<RetrievalElement URI=\"\"
xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />");
if (doc.DocumentElement.OuterXml == "<RetrievalElement URI=\"\"
xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />")
Console.WriteLine ("Ok");
else
Console.WriteLine ("Failed");
}
and my understanding...
In XmlElement.cs, WriteTo, the first line seems to add the namespace in the
element. Right ?
w.WriteStartElement(Prefix, LocalName, NamespaceURI);
Note that in WriteStartElementInternal, namespaceManager.AddNamespace seems
called twice with prefix = "", ns = "http://www.w3.org/2000/09/xmldsig#" -
which seems redundant. I assume that prefix = "" is the default namespace
for the current element.
The next two lines don't add the xmlns prefix again because the
WriteAttributeString (in XmlWriter.cs) is protected against this. So far so
good.
Now we enter the foreach loop...
foreach(XmlNode attributeNode in Attributes)
In the first iteration "URI" is added to the XML output - which was
expected.
In the second iteration "xmlns" is __also__ added to the XML output - but is
already present! The same sanity check (in WriteAttributeString,
XmlWriter.cs) don't catch the dupe (but should it ? or is it for attributes
prefix ?).
Yep - it's logged in BugZilla ;-)
http://bugzilla.ximian.com/show_bug.cgi?id=36871
Thanks a lot
Sebastien Pouliot
Security Architect, Motus Technologies, http://www.motus.com/
work: spouliot@motus.com
home: spouliot@videotron.ca