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

Marcus Bürgel marcus.buergel@gmx.de
Thu, 15 Aug 2002 16:22:09 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_0001_01C24477.E8A1F3C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

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
 

------=_NextPart_000_0001_01C24477.E8A1F3C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<TITLE>Nachricht</TITLE>

<META content=3D"MSHTML 6.00.2716.2200" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial size=3D2>I was =
just a bit=20
playing around with Mono 0.13 it works quite&nbsp;well on my Linux=20
Box.</FONT></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial =
size=3D2>Then&nbsp;I=20
discovered that the Xml support that the Xml support lacks writing the=20
namespaces.</FONT></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial size=3D2>I was =
using=20
XmlDocument directly inserting XmlElement in diffrent namespaces but I =
just got=20
a file with the plain local names.</FONT></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial size=3D2>After =
digging' in=20
the sources of System.Xml I found the bug.</FONT></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial size=3D2>In=20
mcs-0.13\class\System.XML\System.Xml\XmlElement.cs I found the following =

code:</FONT></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;public=20
override void WriteTo (XmlWriter =
w)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;=20
w.WriteStartElement(LocalName);<BR></FONT></SPAN><FONT face=3DArial=20
size=3D2></FONT></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;foreach(XmlNode attributeNode in=20
Attributes)<BR>&nbsp;&nbsp;&nbsp;&nbsp;attributeNode.WriteTo(w);</FONT></=
SPAN></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;WriteContentTo(w);</FONT></SPAN></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;w.WriteEndElement();<BR>&nbsp;&nbsp;}<BR></FON=
T></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial size=3D2>Which =
just emits the=20
Xml element without prefix nor namespace, the fix was quite=20
simple:</FONT></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D093370414-15082002>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;public=20
override void WriteTo (XmlWriter w)<BR>&nbsp;&nbsp;{<BR></FONT>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;w.WriteStartElement(Prefix, LocalName,=20
NamespaceURI);&nbsp;&nbsp;&nbsp; // =
FIXED</FONT></DIV></SPAN></SPAN><SPAN=20
class=3D093370414-15082002><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;foreach(XmlNode attributeNode in=20
Attributes)<BR>&nbsp;&nbsp;&nbsp;&nbsp;attributeNode.WriteTo(w);</FONT></=
SPAN></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;WriteContentTo(w);</FONT></SPAN></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;w.WriteEndElement();<BR>&nbsp;&nbsp;}<BR></FON=
T></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial size=3D2>After =
recompiling=20
System.Xml.dll xml namespaces are correctly written.</FONT></SPAN></DIV>
<DIV><FONT face=3DArial size=3D2></FONT></SPAN><SPAN =
class=3D093370414-15082002><FONT=20
face=3DArial size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial size=3D2>Thanks =
for the=20
really amazing work you're all doing with mono.</FONT></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial size=3D2>I =
would be very=20
pleased if you can add this fix the the official mono=20
source.</FONT></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2>Thanks,</FONT></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial size=3D2>Marcus =

Buergel</FONT></SPAN></DIV>
<DIV><SPAN class=3D093370414-15082002><FONT face=3DArial=20
size=3D2></FONT>&nbsp;</DIV></DIV></SPAN></BODY></HTML>

------=_NextPart_000_0001_01C24477.E8A1F3C0--