[Mono-dev] Bug with System.Xml.XmlDocument.CreateAttribute(, , ) overloading

Atsushi Eno atsushi at ximian.com
Sun Dec 10 21:05:49 EST 2006


Hi,

Good catch :-) I'll fix it in svn. Thanks.

Atsushi Eno

Markus Mauhart wrote:
> Hi,
> 
> 
> I have 2 .NET 2.0 applications, using my own derived MyXmlDocument which
> overload some CreateXxxx functions to insert MyXmlXxxxx nodes into the tree.
> But tested with MONO 1.2.2.1 and 1.18, MyXmlDocument::CreateAttribute(,,)
> is not called when loading from XmlReader.
> 
> AFAICS, the problem lies in function ...
>     private XmlAttribute ReadAttributeNode (XmlReader reader)
> ... which doesnt call the official virtual "CreateAttribute(,,)",
> instead it calls the internal
>     "CreateAttribute(,,,bool atomizedNames, bool checkNamespace)":
> 
> 
>     private XmlAttribute ReadAttributeNode (XmlReader reader)
>     {
>         if (reader.NodeType == XmlNodeType.Element)
>             reader.MoveToFirstAttribute ();
>         else if (reader.NodeType != XmlNodeType.Attribute)
>             throw new InvalidOperationException (MakeReaderErrorMessage
>                             ("bad position to read attribute.", reader));
> --->    XmlAttribute attribute = CreateAttribute
>                                     (reader.Prefix, reader.LocalName
>                                     , reader.NamespaceURI
>                                     , false, false); // different NameTable
> 
> 
> The official virtual "CreateAttribute(,,)" implementation uses other flags:
> 
>     public virtual XmlAttribute CreateAttribute (string prefix, string localName, string namespaceURI)
>     {
> --->    return CreateAttribute (prefix, localName, namespaceURI, false, true);
>     }
> 
> 
> Looking into "XmlAttribute(,,,bool atomizedNames, bool checkNamespace)",
> IMHO the "checkNamespace == false" in ReadAttributeNode(,,) looks like an
> optimization for me, no necessity.
> Hence I suggest in ReadAttributeNode() to replace the call of the internal
> CreateAttribute(,,,,) with a call of the official virtual CreateAttribute(,,).
> 
> 
> Regards,
> Markus.
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 




More information about the Mono-devel-list mailing list