diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2005-12-13 06:59:27 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2005-12-13 06:59:27 +0300 |
commit | 9991cfa13f5868257a74a1eb73f02636a771b4ed (patch) | |
tree | 88b0e55f83732b53de4249ac77f2cc765055b0d9 /mcs/class/System.XML | |
parent | 9a151900ebd8f10754f2fceee7e2e359f918b8d4 (diff) |
2005-12-13 Atsushi Enomoto <atsushi@ximian.com>
* XmlTextReader.cs : when XmlReader.Create() creates this instance,
don't expect strict text declaration. Check SkipTextDeclaration()
on Read().
svn path=/trunk/mcs/; revision=54269
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r-- | mcs/class/System.XML/System.Xml/ChangeLog | 6 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlTextReader.cs | 14 |
2 files changed, 14 insertions, 6 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index 2b99b7c8371..2920bc0bdb2 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,3 +1,9 @@ +2005-12-13 Atsushi Enomoto <atsushi@ximian.com> + + * XmlTextReader.cs : when XmlReader.Create() creates this instance, + don't expect strict text declaration. Check SkipTextDeclaration() + on Read(). + 2005-12-12 Atsushi Enomoto <atsushi@ximian.com> * XmlReader.cs : fixed several misconception in MoveToNextSibling(). diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs index 430fc76c22f..faf1f35f767 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextReader.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs @@ -548,6 +548,7 @@ namespace System.Xml if (startNodeType == XmlNodeType.Attribute) { if (currentAttribute == 0) return false; // already read. + SkipTextDeclaration (); ClearAttributes (); IncrementAttributeToken (); ReadAttributeValueTokens ('"'); @@ -556,6 +557,8 @@ namespace System.Xml readState = ReadState.Interactive; return true; } + if (readState == ReadState.Initial && currentState == XmlNodeType.Element) + SkipTextDeclaration (); if (Binary != null) Binary.Reset (); @@ -1010,12 +1013,10 @@ namespace System.Xml switch (fragType) { case XmlNodeType.Attribute: reader = new StringReader (fragment.ReadToEnd ().Replace ("\"", """)); - SkipTextDeclaration (); break; case XmlNodeType.Element: currentState = XmlNodeType.Element; allowMultipleRoot = true; - SkipTextDeclaration (); break; case XmlNodeType.Document: break; @@ -1951,7 +1952,7 @@ namespace System.Xml // The reader is positioned after "<?xml " private void ReadXmlDeclaration () { - if (currentState != XmlNodeType.None) { + if (!allowMultipleRoot && currentState != XmlNodeType.None) { throw NotWFError ("XML declaration cannot appear in this state."); } currentState = XmlNodeType.XmlDeclaration; @@ -2005,8 +2006,6 @@ namespace System.Xml private void SkipTextDeclaration () { - this.currentState = XmlNodeType.Element; - if (PeekChar () != '<') return; @@ -2084,7 +2083,10 @@ namespace System.Xml } // Encoding value should be checked inside XmlInputStream. } - else + // this condition is to check if this instance is + // not created by XmlReader.Create() (which just + // omits strict text declaration check). + else if (Conformance == ConformanceLevel.Auto) throw NotWFError ("Encoding declaration is mandatory in text declaration."); Expect ("?>"); |