diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2004-09-08 09:49:24 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2004-09-08 09:49:24 +0400 |
commit | e95a1ed5dd6bed5e93be7c95364cb45d9699cb0f (patch) | |
tree | 05f90a617cefc34a1558219dc87ed0461d501dc8 /mcs/class/System.XML | |
parent | ce26bf6f681341661fb0aee98dfa5ab877aba7e0 (diff) |
2004-09-08 Atsushi Enomoto <atsushi@ximian.com>
* XmlReader.cs : evidence is always provided.
* XmlWriter.cs, XmlTextWriter.cs :
added support for ConformanceLevel and OmitXmlDeclaration.
svn path=/trunk/mcs/; revision=33558
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/XmlReader.cs | 1 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlTextWriter.cs | 48 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlWriter.cs | 4 |
4 files changed, 56 insertions, 3 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index 530a0dcf6b4..a03f94bf03c 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,5 +1,11 @@ 2004-09-08 Atsushi Enomoto <atsushi@ximian.com> + * XmlReader.cs : evidence is always provided. + * XmlWriter.cs, XmlTextWriter.cs : + added support for ConformanceLevel and OmitXmlDeclaration. + +2004-09-08 Atsushi Enomoto <atsushi@ximian.com> + * XmlTextReader.cs : Console.WriteLine() injected :( * XmlTextWriter.cs : It it partly supports XmlWriterSettings. * XmlWriter.cs : implemented Create(). diff --git a/mcs/class/System.XML/System.Xml/XmlReader.cs b/mcs/class/System.XML/System.Xml/XmlReader.cs index 7420cda8a12..a9f3546d5d9 100644 --- a/mcs/class/System.XML/System.Xml/XmlReader.cs +++ b/mcs/class/System.XML/System.Xml/XmlReader.cs @@ -57,6 +57,7 @@ namespace System.Xml protected XmlReader () { + evidence = new Evidence (); } #endregion diff --git a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs index ff74f08effb..49d2ea29104 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs @@ -37,7 +37,7 @@ using System.Text; namespace System.Xml { - [MonoTODO ("CheckCharacters; Conformance; NormalizeNewLines; OmitXmlDeclaration")] + [MonoTODO ("CheckCharacters; NormalizeNewLines")] public class XmlTextWriter : XmlWriter { #region Fields @@ -84,6 +84,10 @@ namespace System.Xml bool closeOutput; bool newLineOnAttributes; string newLineChars; + bool outputXmlDeclaration; +#if NET_2_0 + ConformanceLevel conformanceLevel; +#endif #endregion @@ -174,6 +178,21 @@ openElements [openElementCount - 1]).IndentingOverriden; set { closeOutput = value; } } + // As for ConformanceLevel, MS.NET is inconsistent with + // MSDN documentation. For example, even if ConformanceLevel + // is set as .Auto, multiple WriteStartDocument() calls + // result in an error. + // ms-help://MS.NETFramework.v20.en/wd_xml/html/7db8802b-53d8-4735-a637-4d2d2158d643.htm + [MonoTODO] + internal ConformanceLevel ConformanceLevel { + get { return conformanceLevel; } + set { + conformanceLevel = value; + if (value == ConformanceLevel.Fragment) + documentStarted = true; + } + } + internal string IndentChars { // get { return indentChars; } set { indentChars = value == null ? String.Empty : value; } @@ -189,6 +208,10 @@ openElements [openElementCount - 1]).IndentingOverriden; set { newLineOnAttributes = value; } } + internal bool OmitXmlDeclaration { +// get { return !outputXmlDeclaration; } + set { outputXmlDeclaration = !value; } + } #endif public bool Namespaces { @@ -248,6 +271,16 @@ openElements [openElementCount - 1]).IndentingOverriden; #endregion #region Methods +#if NET_2_0 + private void CheckStartDocument () + { + if (outputXmlDeclaration && + conformanceLevel == ConformanceLevel.Document && + ws == WriteState.Start) + WriteStartDocument (); + } +#endif + private void AddMissingElementXmlns () { // output namespace declaration if not exist. @@ -303,6 +336,14 @@ openElements [openElementCount - 1]).IndentingOverriden; private void CheckState () { +#if NET_2_0 + CheckStartDocument (); +#endif + CheckOutputState (); + } + + private void CheckOutputState () + { if (!openWriter) { throw new InvalidOperationException ("The Writer is closed."); } @@ -800,7 +841,8 @@ openElements [openElementCount - 1]).IndentingOverriden; if (hasRoot) throw new XmlException ("WriteStartDocument called twice."); - CheckState (); +// CheckState (); + CheckOutputState (); string encodingFormatting = ""; @@ -829,8 +871,8 @@ openElements [openElementCount - 1]).IndentingOverriden; private void WriteStartElementInternal (string prefix, string localName, string ns) { - hasRoot = true; CheckState (); + hasRoot = true; CloseStartElement (); newAttributeNamespaces.Clear (); userWrittenNamespaces.Clear (); diff --git a/mcs/class/System.XML/System.Xml/XmlWriter.cs b/mcs/class/System.XML/System.Xml/XmlWriter.cs index e94cb9e41a2..2a6b2ee8562 100644 --- a/mcs/class/System.XML/System.Xml/XmlWriter.cs +++ b/mcs/class/System.XML/System.Xml/XmlWriter.cs @@ -163,6 +163,10 @@ namespace System.Xml xtw.CloseOutput = settings.CloseOutput; // NewLineOnAttributes xtw.NewLineOnAttributes = settings.NewLineOnAttributes; + // ConformanceLevel + xtw.ConformanceLevel = settings.ConformanceLevel; + // OmitXmlDeclaration + xtw.OmitXmlDeclaration = settings.OmitXmlDeclaration; return Create (xtw, settings); } |