diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2006-01-13 06:47:20 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2006-01-13 06:47:20 +0300 |
commit | ff0343ec9a5ff32a6a8df8cdf23fc26a927f5b6e (patch) | |
tree | 15648faddfc7cc6d46c2f1f707e84522f4cd3f99 /mcs/class/System.XML/System.Xml | |
parent | b9ce656f6d3bb1aed38739e789b0dd6adb71ce2b (diff) |
2006-01-13 Atsushi Enomoto <atsushi@ximian.com>
merged 55290, 55291, 55309, 55359, 55360, 55364, 55371, 55414, 55415 and
55418 from trunk.
svn path=/tags/mono-1-1-13/mcs/; revision=55476
Diffstat (limited to 'mcs/class/System.XML/System.Xml')
-rw-r--r-- | mcs/class/System.XML/System.Xml/ChangeLog | 25 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/DTDObjectModel.cs | 2 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs | 4 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlTextWriter.cs | 21 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlWriter.cs | 9 |
5 files changed, 54 insertions, 7 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index c7d7c295879..a2498bf3d6c 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,3 +1,28 @@ +2006-01-12 Atsushi Enomoto <atsushi@ximian.com> + + * XmlTextWriter.cs : Do not local duplicate of automatically-created + prefixes (i.e. check local autocreated prefixes other than + namespaces from ancestors). Fixed bug #77086 and #77087. + +2006-01-12 Atsushi Enomoto <atsushi@ximian.com> + + * XmlWriter.cs : use XmlChar.IsNmToken() to check argument and throw + ArgumentException in WriteNmTokenInternal(). + +2006-01-12 Atsushi Enomoto <atsushi@ximian.com> + + * XmlTextWriter.cs : Fixed bug #77094. Only XmlTextWriter checks + such invalid "xml" prefix which is being mapped to different + namespace URI than the predefined one. + Removed comment that does not make sense. + * XmlNamespaceManager.cs : IsValidDeclaration() could be private. + Added some comments. + +2006-01-11 Atsushi Enomoto <atsushi@ximian.com> + + * DTDObjectModel.cs : dtd2xsd fix; set use="optional" when an + attribute is #IMPLIED. + 2006-01-06 Atsushi Enomoto <atsushi@ximian.com> * XmlWriter.cs : In WriteNode(XPathNavigator, bool), Avoid diff --git a/mcs/class/System.XML/System.Xml/DTDObjectModel.cs b/mcs/class/System.XML/System.Xml/DTDObjectModel.cs index e411b8fa08d..bae72caa7ba 100644 --- a/mcs/class/System.XML/System.Xml/DTDObjectModel.cs +++ b/mcs/class/System.XML/System.Xml/DTDObjectModel.cs @@ -833,6 +833,8 @@ namespace Mono.Xml SetLineInfo (a); a.Name = Name; a.DefaultValue = resolvedNormalizedDefaultValue; + if (OccurenceType != DTDAttributeOccurenceType.Required) + a.Use = XmlSchemaUse.Optional; XmlQualifiedName qname = XmlQualifiedName.Empty; ArrayList enumeration = null; diff --git a/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs b/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs index ea6a8b50523..29afff1e604 100644 --- a/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs +++ b/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs @@ -170,9 +170,11 @@ namespace System.Xml decls [declPos].Uri = uri; } - internal static string IsValidDeclaration (string prefix, string uri, bool throwException) + static string IsValidDeclaration (string prefix, string uri, bool throwException) { string message = null; + // It is funky, but it does not check whether prefix + // is equivalent to "xml" in case-insensitive means. if (prefix == PrefixXml && uri != XmlnsXml) message = String.Format ("Prefix \"xml\" can only be bound to the fixed namespace URI \"{0}\". \"{1}\" is invalid.", XmlnsXml, uri); else if (message == null && prefix == "xmlns") 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; diff --git a/mcs/class/System.XML/System.Xml/XmlWriter.cs b/mcs/class/System.XML/System.Xml/XmlWriter.cs index 3870f7e7df6..0010ce4c0da 100644 --- a/mcs/class/System.XML/System.Xml/XmlWriter.cs +++ b/mcs/class/System.XML/System.Xml/XmlWriter.cs @@ -360,16 +360,19 @@ namespace System.Xml internal virtual void WriteNmTokenInternal (string name) { + bool valid = true; #if NET_2_0 switch (Settings.ConformanceLevel) { case ConformanceLevel.Document: case ConformanceLevel.Fragment: - XmlConvert.VerifyNMTOKEN (name); - break; + valid = XmlChar.IsNmToken (name); + break; } #else - XmlConvert.VerifyNMTOKEN (name); + valid = XmlChar.IsNmToken (name); #endif + if (!valid) + throw new ArgumentException ("Argument name is not a valid NMTOKEN."); WriteString (name); } |