diff options
Diffstat (limited to 'mcs/class/System.XML/System.Xml/XmlTextWriter.cs')
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlTextWriter.cs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs index cc86640a281..061d259b364 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs @@ -752,8 +752,6 @@ openElements [openElementCount - 1]).IndentingOverriden; public override void WriteStartAttribute (string prefix, string localName, string ns) { if (prefix == "xml") { - // MS.NET looks to allow other names than - // lang and space (e.g. xml:link, xml:hack). ns = XmlNamespaceManager.XmlnsXml; if (localName == "lang") openXmlLang = true; @@ -799,7 +797,7 @@ openElements [openElementCount - 1]).IndentingOverriden; string formatPrefix = ""; if (ns != String.Empty && prefix != "xmlns") { - string existingPrefix = namespaceManager.LookupPrefix (ns, false); + string existingPrefix = GetExistingPrefix (ns); if (existingPrefix == null || existingPrefix == "") { bool createPrefix = false; @@ -854,6 +852,15 @@ openElements [openElementCount - 1]).IndentingOverriden; } } + string GetExistingPrefix (string ns) + { + if (newAttributeNamespaces.ContainsValue (ns)) + foreach (DictionaryEntry de in newAttributeNamespaces) + if (de.Value as string == ns) + return (string) de.Key; + return namespaceManager.LookupPrefix (ns, false); + } + private string CheckNewPrefix (bool createPrefix, string prefix, string ns) { do { @@ -916,6 +923,14 @@ openElements [openElementCount - 1]).IndentingOverriden; if ((prefix != null && prefix.Length > 0) && ((ns == null))) throw ArgumentError ("Cannot use a prefix with an empty namespace."); + // Considering the fact that WriteStartAttribute() + // automatically changes argument namespaceURI, this + // is kind of silly implementation. See bug #77094. + if (Namespaces && + ns != XmlNamespaceManager.XmlnsXml && + String.Compare (prefix, "xml", true) == 0) + throw new ArgumentException ("A prefix cannot be equivalent to \"xml\" in case-insensitive match."); + // ignore non-namespaced node's prefix. if (ns == null || ns == String.Empty) prefix = String.Empty; |