+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-\r
+//\r
+// System.Xml.XmlDeclaration\r
+//\r
+// Author:\r
+// Daniel Weber (daniel-weber@austin.rr.com)\r
+//\r
+// (C) 2001 Daniel Weber\r
+\r
using System;\r
\r
namespace System.Xml\r
/// <summary>\r
/// \r
/// </summary>\r
- public class XmlDeclaration\r
+ public class XmlDeclaration : XmlLinkedNode\r
{\r
// Private data members\r
+ private string Fencoding = "UTF-8";\r
+ bool Fstandalone;\r
\r
// public properties\r
+ /// <summary>\r
+ /// Get/Set the encoding used for the document\r
+ /// Typical values are "UTF-8", "UTF-16", "ISO-8859-nn" (where n is 0-9).\r
+ /// If not defined, "UTF-8" is assumed.\r
+ /// encoding is not case sensitive.\r
+ /// </summary>\r
+ public string Encoding \r
+ {\r
+ get\r
+ {\r
+ return Fencoding;\r
+ }\r
+\r
+ set\r
+ {\r
+ string val = value.ToUpper();\r
+\r
+ if ( (val == "UTF-8") | ( val == "UTF-16") )\r
+ {\r
+ Fencoding = value;\r
+ return;\r
+ }\r
+ else\r
+ {\r
+ if ( ( val.StartsWith( "ISO-8859-" ) ) & (val.Length == 10) )\r
+ {\r
+ try\r
+ {\r
+ int code = System.Convert.ToInt32( val.Substring(9,1) );\r
+ Fencoding = value;\r
+ }\r
+ catch\r
+ {\r
+ throw new NotImplementedException("Encoding " + value + " is not supported");\r
+ }\r
+\r
+ }\r
+\r
+ \r
+ }\r
+ }\r
+ }\r
\r
+ /// <summary>\r
+ /// Get the local name of the declaration. Returns "xml"\r
+ /// </summary>\r
+ public override string LocalName \r
+ {\r
+ get\r
+ {\r
+ return "xml";\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get the name of the node. For XmlDeclaration, returns "xml".\r
+ /// </summary>\r
+ public override string Name \r
+ {\r
+ get\r
+ {\r
+ return "xml";\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Return the node type. For XmlDeclaration, returns XmlNodeType.XmlDeclaration.\r
+ /// </summary>\r
+ public override XmlNodeType NodeType \r
+ {\r
+ get\r
+ {\r
+ return XmlNodeType.XmlDeclaration;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get/Set the value of the standalone attribute.\r
+ /// "yes" => no external DTD required.\r
+ /// "no" => external data sources required.\r
+ /// Silently fails if Set to invalid value.\r
+ /// Not case sensitive.\r
+ /// </summary>\r
+ public string Standalone {\r
+ get\r
+ {\r
+ if (Fstandalone) \r
+ return "yes";\r
+ else\r
+ return "no";\r
+ }\r
+\r
+ set\r
+ {\r
+ if (value.ToUpper() == "YES")\r
+ Fstandalone = true;\r
+ if (value.ToUpper() == "NO")\r
+ Fstandalone = false;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get the xml version of the file. Returns "1.0"\r
+ /// </summary>\r
+ public string Version \r
+ {\r
+ get\r
+ {\r
+ return "1.0";\r
+ }\r
+ }\r
\r
// Public Methods\r
+ /// <summary>\r
+ /// Overriden. Returns a cloned version of this node.\r
+ /// Serves as a copy constructor. Duplicate node has no parent.\r
+ /// </summary>\r
+ /// <param name="deep">Create deep copy. N/A for XmlDeclaration.</param>\r
+ /// <returns>Cloned node.</returns>\r
+ public override XmlNode CloneNode(bool deep)\r
+ {\r
+ // TODO - implement XmlDeclration.CloneNode()\r
+ throw new NotImplementedException("XmlDeclration.CloneNode() not implemented");\r
+ }\r
+\r
+ /// <summary>\r
+ /// Save the children of this node to the passed XmlWriter. Since an XmlDeclaration has \r
+ /// no children, this call has no effect.\r
+ /// </summary>\r
+ /// <param name="w"></param>\r
+ public override void WriteContentTo(XmlWriter w)\r
+ {\r
+ // Nothing to do - no children.\r
+ }\r
+\r
+ /// <summary>\r
+ /// Saves the node to the specified XmlWriter\r
+ /// </summary>\r
+ /// <param name="w">XmlWriter to writ to.</param>\r
+ public override void WriteTo(XmlWriter w)\r
+ {\r
+ // TODO - implement XmlDeclration.WriteTo()\r
+ throw new NotImplementedException("XmlDeclaration.WriteTo() not implemented");\r
+ }\r
+\r
+ // Constructors\r
+ internal XmlDeclaration( XmlDocument aOwnerDoc) : base(aOwnerDoc)\r
+ {\r
+ }\r
}\r
}\r