[Mono-list] Bug in System.Xml.XmlElement

Jason Diamond jason@injektilo.org
16 Aug 2002 20:21:49 -0700


Thanks, Marcus.

Your fix is checked in along with a test to prove it keeps working. :-)

Jason

On Thu, 2002-08-15 at 07:22, Marcus Bürgel wrote:
> Hi,
>  
> I was just a bit playing around with Mono 0.13 it works quite well on my
> Linux Box.
> Then I discovered that the Xml support that the Xml support lacks
> writing the namespaces.
> I was using XmlDocument directly inserting XmlElement in diffrent
> namespaces but I just got a file with the plain local names.
>  
> After digging' in the sources of System.Xml I found the bug.
>  
> In mcs-0.13\class\System.XML\System.Xml\XmlElement.cs I found the
> following code:
>   public override void WriteTo (XmlWriter w)
>   {
>     w.WriteStartElement(LocalName);
> 
>    foreach(XmlNode attributeNode in Attributes)
>     attributeNode.WriteTo(w);
>  
>    WriteContentTo(w);
>  
>    w.WriteEndElement();
>   }
> 
> Which just emits the Xml element without prefix nor namespace, the fix
> was quite simple:
>  
>   public override void WriteTo (XmlWriter w)
>   {
> 
>    w.WriteStartElement(Prefix, LocalName, NamespaceURI);    // FIXED
>    foreach(XmlNode attributeNode in Attributes)
>     attributeNode.WriteTo(w);
>  
>    WriteContentTo(w);
>  
>    w.WriteEndElement();
>   }
> 
> After recompiling System.Xml.dll xml namespaces are correctly written.
>  
> Thanks for the really amazing work you're all doing with mono.
>  
> I would be very pleased if you can add this fix the the official mono
> source.
>  
> Thanks,
> Marcus Buergel
>