diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2006-01-13 08:03:39 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2006-01-13 08:03:39 +0300 |
commit | 5d8f9644c4d66346424ccfc508ea1905f6d35314 (patch) | |
tree | b3206bf8e8af8216699a8a22977876d8ba29a288 /mcs/class/System.XML/System.Xml/XmlTextWriter.cs | |
parent | 19b6313b555bef2a7a3315d57e867a148a1380c7 (diff) |
2006-01-13 Atsushi Enomoto <atsushi@ximian.com>
* XmlTextWriter.cs : Fixed bug #77082.
When the state was Start, after WriteProcessingInstruction() and
WriteWhitespace() change it to Prolog.
After WriteDocType() set state to WriteState.Element.
* XmlTextWriterTests.cs : added some tests for XMLdecl state check.
* XslTransformTests.cs : Output_Indent_Xml_DocType() is working now.
svn path=/trunk/mcs/; revision=55487
Diffstat (limited to 'mcs/class/System.XML/System.Xml/XmlTextWriter.cs')
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlTextWriter.cs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs index 061d259b364..6b9d3163e68 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs @@ -518,7 +518,11 @@ openElements [openElementCount - 1]).IndentingOverriden; if (name == null || name.Trim (XmlChar.WhitespaceChars).Length == 0) throw ArgumentError ("Invalid DOCTYPE name", "name"); - if (ws == WriteState.Prolog && formatting == Formatting.Indented) + CheckState (); + if (ws != WriteState.Start && ws != WriteState.Prolog) + throw new InvalidOperationException (String.Format ("Doctype is not allowed at '{0}' state.", ws)); + + if (documentStarted && formatting == Formatting.Indented) w.WriteLine (); w.Write ("<!DOCTYPE "); @@ -546,6 +550,8 @@ openElements [openElementCount - 1]).IndentingOverriden; } w.Write('>'); + + ws = WriteState.Element; } public override void WriteEndAttribute () @@ -701,7 +707,7 @@ openElements [openElementCount - 1]).IndentingOverriden; if ((text.IndexOf("?>") > 0)) throw ArgumentError ("Processing instruction cannot contain \"?>\" as its value."); - CheckState (); + CheckOutputState (); CloseStartElement (); WriteIndent (); @@ -710,6 +716,9 @@ openElements [openElementCount - 1]).IndentingOverriden; w.Write (' '); w.Write (text); w.Write ("?>"); + + if (ws == WriteState.Start) + ws = WriteState.Prolog; } public override void WriteQualifiedName (string localName, string ns) @@ -1150,13 +1159,13 @@ openElements [openElementCount - 1]).IndentingOverriden; w.Write (';'); } - public override void WriteWhitespace (string ws) + public override void WriteWhitespace (string value) { - if (ws == null || ws.Length == 0) { + if (value == null || value.Length == 0) { throw ArgumentError ("Only white space characters should be used."); } - if (!XmlChar.IsWhitespace (ws)) + if (!XmlChar.IsWhitespace (value)) throw ArgumentError ("Invalid Whitespace"); CheckState (); @@ -1166,7 +1175,10 @@ openElements [openElementCount - 1]).IndentingOverriden; CloseStartElement (); } - w.Write (ws); + w.Write (value); + + if (ws == WriteState.Start) + ws = WriteState.Prolog; } private Exception ArgumentError (string message) |