Fixed typo in XmlDocument.Load that was duplicating the LocalName in the Prefix.
[mono.git] / mcs / class / System.XML / System.Xml / XmlDeclaration.cs
1 // -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-\r
2 //\r
3 // System.Xml.XmlDeclaration\r
4 //\r
5 // Author:\r
6 //   Daniel Weber (daniel-weber@austin.rr.com)\r
7 //\r
8 // (C) 2001 Daniel Weber\r
9 \r
10 using System;\r
11 \r
12 namespace System.Xml\r
13 {\r
14         /// <summary>\r
15         /// \r
16         /// </summary>\r
17         public class XmlDeclaration : XmlLinkedNode\r
18         {\r
19                 // Private data members\r
20                 private string Fencoding = "UTF-8";\r
21                 bool Fstandalone;\r
22 \r
23                 // public properties\r
24                 /// <summary>\r
25                 /// Get/Set the encoding used for the document\r
26                 /// Typical values are "UTF-8", "UTF-16", "ISO-8859-nn" (where n is 0-9).\r
27                 /// If not defined, "UTF-8" is assumed.\r
28                 /// encoding is not case sensitive.\r
29                 /// </summary>\r
30                 public string Encoding \r
31                 {\r
32                         get\r
33                         {\r
34                                 return Fencoding;\r
35                         }\r
36 \r
37                         set\r
38                         {\r
39                                 string val = value.ToUpper();\r
40 \r
41                                 if ( (val == "UTF-8") | ( val == "UTF-16") )\r
42                                 {\r
43                                         Fencoding = value;\r
44                                         return;\r
45                                 }\r
46                                 else\r
47                                 {\r
48                                         if ( ( val.StartsWith( "ISO-8859-" ) ) & (val.Length == 10) )\r
49                                         {\r
50                                                 try\r
51                                                 {\r
52                                                         int code = System.Convert.ToInt32( val.Substring(9,1) );\r
53                                                         Fencoding = value;\r
54                                                 }\r
55                                                 catch\r
56                                                 {\r
57                                                         throw new NotImplementedException("Encoding " + value + " is not supported");\r
58                                                 }\r
59 \r
60                                         }\r
61 \r
62                                         \r
63                                 }\r
64                         }\r
65                 }\r
66                 \r
67                 /// <summary>\r
68                 /// Get the local name of the declaration.  Returns "xml"\r
69                 /// </summary>\r
70                 public override string LocalName \r
71                 {\r
72                         get\r
73                         {\r
74                                 return "xml";\r
75                         }\r
76                 }\r
77 \r
78                 /// <summary>\r
79                 /// Get the name of the node.  For XmlDeclaration, returns "xml".\r
80                 /// </summary>\r
81                 public override string Name \r
82                 {\r
83                         get\r
84                         {\r
85                                 return "xml";\r
86                         }\r
87                 }\r
88 \r
89                 /// <summary>\r
90                 /// Return the node type.  For XmlDeclaration, returns XmlNodeType.XmlDeclaration.\r
91                 /// </summary>\r
92                 public override XmlNodeType NodeType \r
93                 {\r
94                         get\r
95                         {\r
96                                 return XmlNodeType.XmlDeclaration;\r
97                         }\r
98                 }\r
99 \r
100                 /// <summary>\r
101                 /// Get/Set the value of the standalone attribute.\r
102                 /// "yes" => no external DTD required.\r
103                 /// "no" => external data sources required.\r
104                 /// Silently fails if Set to invalid value.\r
105                 /// Not case sensitive.\r
106                 /// </summary>\r
107                 public string Standalone {\r
108                         get\r
109                         {\r
110                                 if (Fstandalone) \r
111                                         return "yes";\r
112                                 else\r
113                                         return "no";\r
114                         }\r
115 \r
116                         set\r
117                         {\r
118                                 if (value.ToUpper() == "YES")\r
119                                         Fstandalone = true;\r
120                                 if (value.ToUpper() == "NO")\r
121                                         Fstandalone = false;\r
122                         }\r
123                 }\r
124 \r
125                 /// <summary>\r
126                 /// Get the xml version of the file.  Returns "1.0"\r
127                 /// </summary>\r
128                 public string Version \r
129                 {\r
130                         get\r
131                         {\r
132                                 return "1.0";\r
133                         }\r
134                 }\r
135 \r
136                 // Public Methods\r
137                 /// <summary>\r
138                 /// Overriden.  Returns a cloned version of this node.\r
139                 /// Serves as a copy constructor.  Duplicate node has no parent.\r
140                 /// </summary>\r
141                 /// <param name="deep">Create deep copy.  N/A for XmlDeclaration.</param>\r
142                 /// <returns>Cloned node.</returns>\r
143                 public override XmlNode CloneNode(bool deep)\r
144                 {\r
145                         // TODO - implement XmlDeclration.CloneNode()\r
146                         throw new NotImplementedException("XmlDeclration.CloneNode() not implemented");\r
147                 }\r
148 \r
149                 /// <summary>\r
150                 /// Save the children of this node to the passed XmlWriter.  Since an XmlDeclaration has \r
151                 /// no children, this call has no effect.\r
152                 /// </summary>\r
153                 /// <param name="w"></param>\r
154                 public override void WriteContentTo(XmlWriter w)\r
155                 {\r
156                         // Nothing to do - no children.\r
157                 }\r
158 \r
159                 /// <summary>\r
160                 /// Saves the node to the specified XmlWriter\r
161                 /// </summary>\r
162                 /// <param name="w">XmlWriter to writ to.</param>\r
163                 public override void WriteTo(XmlWriter w)\r
164                 {\r
165                         // TODO - implement XmlDeclration.WriteTo()\r
166                         throw new NotImplementedException("XmlDeclaration.WriteTo() not implemented");\r
167                 }\r
168 \r
169                 // Constructors\r
170                 internal XmlDeclaration( XmlDocument aOwnerDoc) : base(aOwnerDoc)\r
171                 {\r
172                 }\r
173         }\r
174 }\r