namespace System.Xml
{
- [MonoTODO ("CheckCharacters; Conformance; NormalizeNewLines; OmitXmlDeclaration")]
+ [MonoTODO ("CheckCharacters; NormalizeNewLines")]
public class XmlTextWriter : XmlWriter
{
#region Fields
bool closeOutput;
bool newLineOnAttributes;
string newLineChars;
+ bool outputXmlDeclaration;
+#if NET_2_0
+ ConformanceLevel conformanceLevel;
+#endif
#endregion
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; }
set { newLineOnAttributes = value; }
}
+ internal bool OmitXmlDeclaration {
+// get { return !outputXmlDeclaration; }
+ set { outputXmlDeclaration = !value; }
+ }
#endif
public bool Namespaces {
#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.
private void CheckState ()
{
+#if NET_2_0
+ CheckStartDocument ();
+#endif
+ CheckOutputState ();
+ }
+
+ private void CheckOutputState ()
+ {
if (!openWriter) {
throw new InvalidOperationException ("The Writer is closed.");
}
if (hasRoot)
throw new XmlException ("WriteStartDocument called twice.");
- CheckState ();
+// CheckState ();
+ CheckOutputState ();
string encodingFormatting = "";
private void WriteStartElementInternal (string prefix, string localName, string ns)
{
- hasRoot = true;
CheckState ();
+ hasRoot = true;
CloseStartElement ();
newAttributeNamespaces.Clear ();
userWrittenNamespaces.Clear ();