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
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2005-02-24 17:20:00 +0300
committerAtsushi Eno <atsushieno@gmail.com>2005-02-24 17:20:00 +0300
commitb7a95b15700a8616af34d1caa095042aedbe6a13 (patch)
tree50f3051f301b73b4d2822c74a0d5d92b32e857cc /mcs/class/System.XML/System.Xml/XmlTextWriter.cs
parent4b856a8c039c1b1f6e552eb5c1f72ae48187dd5b (diff)
2005-02-24 Atsushi Enomoto <atsushi@ximian.com>
* XmlTextWriter.cs : WriteString() should be valid when WriteStartDocument() was not called. * XmlTextWriterTests.cs : Test for call to WriteRaw() -> WriteString() svn path=/trunk/mcs/; revision=41159
Diffstat (limited to 'mcs/class/System.XML/System.Xml/XmlTextWriter.cs')
-rw-r--r--mcs/class/System.XML/System.Xml/XmlTextWriter.cs12
1 files changed, 10 insertions, 2 deletions
diff --git a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs
index 868026f93e5..9b7101e7e7d 100644
--- a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs
+++ b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs
@@ -69,6 +69,7 @@ namespace System.Xml
string openElementPrefix;
string openElementNS;
bool hasRoot = false;
+ bool isDocumentEntity = false;
Hashtable newAttributeNamespaces = new Hashtable ();
Hashtable userWrittenNamespaces = new Hashtable ();
StringBuilder cachedStringBuilder;
@@ -848,6 +849,7 @@ openElements [openElementCount - 1]).IndentingOverriden;
if (hasRoot)
throw new XmlException ("WriteStartDocument called twice.");
+ isDocumentEntity = true;
// CheckState ();
CheckOutputState ();
@@ -930,8 +932,14 @@ openElements [openElementCount - 1]).IndentingOverriden;
public override void WriteString (string text)
{
- if (ws == WriteState.Prolog)
- throw new InvalidOperationException ("Token content in state Prolog would result in an invalid XML document.");
+ switch (ws) {
+ case WriteState.Start:
+ case WriteState.Prolog:
+ if (isDocumentEntity)
+ throw new InvalidOperationException ("Token content in state Prolog would result in an invalid XML document.");
+ ws = WriteState.Content;
+ break;
+ }
WriteStringInternal (text, true);