Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2004-09-07 10:37:45 +0400
committerAtsushi Eno <atsushieno@gmail.com>2004-09-07 10:37:45 +0400
commite8a49299fd275fbc4993a48939fa7763ed514bcf (patch)
treec568c44b9eba8aa64eccb4e5edd4e00286cdc9e4 /mcs
parent63099a1f1205a3f49506eb1ac55f16b51c3fad0d (diff)
2004-09-07 Atsushi Enomoto <atsushi@ximian.com>
* XmlReader.cs, XmlTextReader.cs : Added NET_2_0 CheckCharacters support. svn path=/trunk/mcs/; revision=33475
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.XML/System.Xml/ChangeLog5
-rw-r--r--mcs/class/System.XML/System.Xml/XmlReader.cs23
-rw-r--r--mcs/class/System.XML/System.Xml/XmlTextReader.cs44
3 files changed, 49 insertions, 23 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog
index 009d70b5221..95c1dda43a0 100644
--- a/mcs/class/System.XML/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/System.Xml/ChangeLog
@@ -1,3 +1,8 @@
+2004-09-07 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlReader.cs, XmlTextReader.cs :
+ Added NET_2_0 CheckCharacters support.
+
2004-09-06 Atsushi Enomoto <atsushi@ximian.com>
* XmlNode.cs : GetEnumerator() does not have to create ChildNodes
diff --git a/mcs/class/System.XML/System.Xml/XmlReader.cs b/mcs/class/System.XML/System.Xml/XmlReader.cs
index c0ab36f4139..2a4922b026b 100644
--- a/mcs/class/System.XML/System.Xml/XmlReader.cs
+++ b/mcs/class/System.XML/System.Xml/XmlReader.cs
@@ -204,41 +204,50 @@ namespace System.Xml
return Create (reader, new XmlUrlResolver (), settings);
}
- [MonoTODO ("CheckCharacters, ConformanceLevel, IgnoreSchemaXXX etc.")]
+ [MonoTODO ("ConformanceLevel, IgnoreSchemaXXX etc.")]
public static XmlReader Create (XmlReader reader, XmlResolver resolver, XmlReaderSettings settings)
{
return CreateFilteredXmlReader (reader, resolver, settings);
}
- [MonoTODO ("CheckCharacters, ConformanceLevel, IgnoreSchemaXXX etc.; Encoding")]
+ [MonoTODO ("ConformanceLevel, IgnoreSchemaXXX etc.; Encoding")]
public static XmlReader Create (string url, Encoding encoding, XmlResolver resolver, XmlReaderSettings settings)
{
return CreateCustomizedTextReader (new XmlTextReader (url), resolver, settings);
}
- [MonoTODO ("CheckCharacters, ConformanceLevel, IgnoreSchemaXXX etc.")]
+ [MonoTODO ("ConformanceLevel, IgnoreSchemaXXX etc.")]
public static XmlReader Create (TextReader reader, string baseUri, XmlResolver resolver, XmlReaderSettings settings)
{
return CreateCustomizedTextReader (new XmlTextReader (baseUri, reader), resolver, settings);
}
- [MonoTODO ("CheckCharacters, ConformanceLevel, IgnoreSchemaXXX etc.")]
+ [MonoTODO ("ConformanceLevel, IgnoreSchemaXXX etc.")]
public static XmlReader Create (Stream stream, string baseUri, Encoding encoding, XmlResolver resolver, XmlReaderSettings settings)
{
- return CreateCustomizedTextReader (encoding == null ? new XmlTextReader (baseUri, stream) : new XmlTextReader (baseUri, new StreamReader (stream, encoding)), resolver, settings);
+ return CreateCustomizedTextReader (
+ encoding == null ?
+ new XmlTextReader (baseUri, stream) :
+ new XmlTextReader (baseUri, new StreamReader (stream, encoding)),
+ resolver,
+ settings);
}
private static XmlReader CreateCustomizedTextReader (XmlTextReader reader, XmlResolver resolver, XmlReaderSettings settings)
{
reader.XmlResolver = resolver;
+ // Normalization is set true by default.
+ reader.Normalization = true;
if (settings == null)
settings = new XmlReaderSettings ();
if (settings.ProhibitDtd)
reader.ProhibitDtd = true;
+
if (!settings.CheckCharacters)
- throw new NotImplementedException ();
+ reader.CharacterChecking = false;
+
// I guess it might be changed in 2.0 RTM to set true
// as default, or just disappear. It goes against
// XmlTextReader's default usage and users will have
@@ -741,7 +750,7 @@ namespace System.Xml
[MonoTODO]
public virtual object ReadTypedValue ()
{
- throw new NotImplementedException ();
+ return ReadAsObject (ValueType);
}
[MonoTODO]
diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs
index fe111523bf8..e856b887f3c 100644
--- a/mcs/class/System.XML/System.Xml/XmlTextReader.cs
+++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs
@@ -162,8 +162,14 @@ namespace System.Xml
public override bool CanResolveEntity {
get { return true; }
}
+
#endif
+ internal bool CharacterChecking {
+ get { return checkCharacters && normalization; }
+ set { checkCharacters = false; }
+ }
+
// for XmlReaderSettings.CloseInput support
internal bool CloseInput {
get { return closeInput; }
@@ -1112,6 +1118,7 @@ namespace System.Xml
private XmlResolver resolver = new XmlUrlResolver ();
private bool normalization = false;
+ private bool checkCharacters;
private bool prohibitDtd = false;
private bool closeInput = true;
private EntityHandling entityHandling; // 2.0
@@ -1168,6 +1175,13 @@ namespace System.Xml
shouldSkipUntilEndTag = false;
base64CacheStartsAt = -1;
+ checkCharacters = true;
+#if NET_2_0
+if (Settings != null)
+Console.WriteLine ("Settings.CheckCharacters = " + Settings.CheckCharacters);
+ if (Settings != null)
+ checkCharacters = Settings.CheckCharacters;
+#endif
prohibitDtd = false;
closeInput = true;
entityHandling = EntityHandling.ExpandCharEntities;
@@ -1801,9 +1815,9 @@ namespace System.Xml
ReadChar (); // ';'
// There is no way to save surrogate pairs...
- if (normalization && XmlChar.IsInvalid (value))
+ if (CharacterChecking && XmlChar.IsInvalid (value))
throw new XmlException (this as IXmlLineInfo,
- "Referenced character was not allowed in XML.");
+ "Referenced character was not allowed in XML. Normalization is " + normalization + ", checkCharacters = " + checkCharacters);
return value;
}
@@ -1966,7 +1980,7 @@ namespace System.Xml
if (PeekChar () == '#') {
ReadChar ();
ch = ReadCharacterReference ();
- if (normalization && XmlChar.IsInvalid (ch))
+ if (CharacterChecking && XmlChar.IsInvalid (ch))
throw new XmlException (this as IXmlLineInfo,
"Not allowed character was found.");
AppendValueChar (ch);
@@ -1991,7 +2005,7 @@ namespace System.Xml
AppendValueChar (predefined);
break;
default:
- if (normalization && XmlChar.IsInvalid (ch))
+ if (CharacterChecking && XmlChar.IsInvalid (ch))
throw new XmlException (this, "Invalid character was found.");
AppendValueChar (ch);
break;
@@ -2057,7 +2071,7 @@ namespace System.Xml
break;
}
- if (normalization && XmlChar.IsInvalid (ch))
+ if (CharacterChecking && XmlChar.IsInvalid (ch))
throw new XmlException (this, "Invalid character was found.");
AppendValueChar (ch);
}
@@ -2302,18 +2316,16 @@ namespace System.Xml
skip = true;
}
}
- if (normalization) {
- if (ch == '\r') {
- ch = PeekChar ();
- if (ch != '\n')
- // append '\n' instead of '\r'.
- AppendValueChar ('\n');
- // otherwise, discard '\r'.
- continue;
- }
- else if (XmlChar.IsInvalid (ch))
- throw new XmlException (this, "Invalid character was found.");
+ if (normalization && ch == '\r') {
+ ch = PeekChar ();
+ if (ch != '\n')
+ // append '\n' instead of '\r'.
+ AppendValueChar ('\n');
+ // otherwise, discard '\r'.
+ continue;
}
+ if (CharacterChecking && XmlChar.IsInvalid (ch))
+ throw new XmlException (this, "Invalid character was found.");
AppendValueChar (ch);
}