rewrote XmlNode with touchups to XmlDocument, XmlElement, and XmlLinkedNode
[mono.git] / mcs / class / System.XML / System.Xml / XmlNode.cs
1 //
2 // System.Xml.XmlProcessingInstruction
3 //
4 // Author:
5 //   Kral Ferch <kral_ferch@hotmail.com>
6 //
7 // (C) 2002 Kral Ferch
8 //
9
10 using System;
11 using System.Collections;
12 using System.Xml.XPath;
13
14 namespace System.Xml
15 {
16         public abstract class XmlNode : ICloneable, IEnumerable, IXPathNavigable
17         {
18                 XmlDocument ownerDocument;
19                 XmlNode parentNode;
20
21                 #region Constructors
22
23                 protected internal XmlNode(XmlDocument ownerDocument)
24                 {
25                         this.ownerDocument = ownerDocument;
26                 }
27
28                 #endregion
29
30                 #region Properties
31
32                 public virtual XmlAttributeCollection Attributes
33                 {
34                         get { return null; }
35                 }
36
37                 [MonoTODO]
38                 public virtual string BaseURI
39                 {
40                         get { throw new NotImplementedException (); }
41                 }
42
43                 [MonoTODO]
44                 public virtual XmlNodeList ChildNodes
45                 {
46                         get { throw new NotImplementedException (); }
47                 }
48
49                 public virtual XmlNode FirstChild
50                 {
51                         get {
52                                 if (LastChild != null) {
53                                         return LastLinkedChild.NextLinkedSibling;
54                                 }
55                                 else {
56                                         return null;
57                                 }
58                         }
59                 }
60
61                 public virtual bool HasChildNodes
62                 {
63                         get { return LastChild != null; }
64                 }
65
66                 [MonoTODO]
67                 public virtual string InnerText
68                 {
69                         get { throw new NotImplementedException (); }
70                         set { throw new NotImplementedException (); }
71                 }
72
73                 [MonoTODO]
74                 public virtual string InnerXml
75                 {
76                         get { throw new NotImplementedException (); }
77                         set { throw new NotImplementedException (); }
78                 }
79
80                 [MonoTODO]
81                 public virtual bool IsReadOnly
82                 {
83                         get { throw new NotImplementedException (); }
84                 }
85
86                 [MonoTODO]
87                 public virtual XmlElement this[string name]
88                 {
89                         get { throw new NotImplementedException (); }
90                 }
91
92                 [MonoTODO]
93                 public virtual XmlElement this[string localname, string ns]
94                 {
95                         get { throw new NotImplementedException (); }
96                 }
97
98                 public virtual XmlNode LastChild
99                 {
100                         get { return LastLinkedChild; }
101                 }
102
103                 internal virtual XmlLinkedNode LastLinkedChild
104                 {
105                         get { return null; }
106                         set { }
107                 }
108
109                 [MonoTODO]
110                 public abstract string LocalName
111                 {
112                         get;
113                 }
114
115                 [MonoTODO]
116                 public abstract string Name
117                 {
118                         get;
119                 }
120
121                 [MonoTODO]
122                 public virtual string NamespaceURI
123                 {
124                         get { throw new NotImplementedException (); }
125                 }
126
127                 public virtual XmlNode NextSibling
128                 {
129                         get { return null; }
130                 }
131
132                 [MonoTODO]
133                 public abstract XmlNodeType NodeType
134                 {
135                         get;
136                 }
137
138                 [MonoTODO]
139                 public virtual string OuterXml
140                 {
141                         get { throw new NotImplementedException (); }
142                 }
143
144                 public virtual XmlDocument OwnerDocument
145                 {
146                         get { return ownerDocument; }
147                 }
148
149                 public virtual XmlNode ParentNode
150                 {
151                         get { return parentNode; }
152                 }
153
154                 [MonoTODO]
155                 public virtual string Prefix
156                 {
157                         get { throw new NotImplementedException (); }
158                         set { throw new NotImplementedException (); }
159                 }
160
161                 public virtual XmlNode PreviousSibling
162                 {
163                         get { return null; }
164                 }
165
166                 [MonoTODO]
167                 public virtual string Value
168                 {
169                         get { throw new NotImplementedException (); }
170                         set { throw new NotImplementedException (); }
171                 }
172
173                 #endregion
174
175                 #region Methods
176
177                 public virtual XmlNode AppendChild (XmlNode newChild)
178                 {
179                         if ((NodeType == XmlNodeType.Document) || (NodeType == XmlNodeType.Element)) {
180                                 LastLinkedChild = (XmlLinkedNode) newChild;
181                                 return LastChild;
182                         }
183                         else {
184                                 throw new InvalidOperationException();
185                         }
186                 }
187
188                 [MonoTODO]
189                 public virtual XmlNode Clone ()
190                 {
191                         throw new NotImplementedException ();
192                 }
193
194                 public abstract XmlNode CloneNode (bool deep);
195
196                 [MonoTODO]
197                 public XPathNavigator CreateNavigator ()
198                 {
199                         throw new NotImplementedException ();
200                 }
201
202                 [MonoTODO]
203                 public IEnumerator GetEnumerator ()
204                 {
205                         throw new NotImplementedException ();
206                 }
207
208                 [MonoTODO]
209                 public virtual string GetNamespaceOfPrefix (string prefix)
210                 {
211                         throw new NotImplementedException ();
212                 }
213
214                 [MonoTODO]
215                 public virtual string GetPrefixOfNamespace (string namespaceURI)
216                 {
217                         throw new NotImplementedException ();
218                 }
219
220                 object ICloneable.Clone ()
221                 {
222                         return Clone ();
223                 }
224
225                 IEnumerator IEnumerable.GetEnumerator ()
226                 {
227                         return GetEnumerator ();
228                 }
229
230                 [MonoTODO]
231                 public virtual XmlNode InsertAfter (XmlNode newChild, XmlNode refChild)
232                 {
233                         throw new NotImplementedException ();
234                 }
235
236                 [MonoTODO]
237                 public virtual XmlNode InsertBefore (XmlNode newChild, XmlNode refChild)
238                 {
239                         throw new NotImplementedException ();
240                 }
241
242                 [MonoTODO]
243                 public virtual void Normalize ()
244                 {
245                         throw new NotImplementedException ();
246                 }
247
248                 [MonoTODO]
249                 public virtual XmlNode PrependChild (XmlNode newChild)
250                 {
251                         throw new NotImplementedException ();
252                 }
253
254                 public virtual void RemoveAll ()
255                 {
256                         LastLinkedChild = null;
257                 }
258
259                 [MonoTODO]
260                 public virtual XmlNode RemoveChild (XmlNode oldChild)
261                 {
262                         throw new NotImplementedException ();
263                 }
264
265                 [MonoTODO]
266                 public virtual XmlNode ReplaceChild (XmlNode newChild, XmlNode oldChild)
267                 {
268                         throw new NotImplementedException ();
269                 }
270
271                 [MonoTODO]
272                 public virtual XmlNodeList SelectNodes (string xpath)
273                 {
274                         throw new NotImplementedException ();
275                 }
276
277                 [MonoTODO]
278                 public virtual XmlNodeList SelectNodes (string xpath, XmlNamespaceManager nsmgr)
279                 {
280                         throw new NotImplementedException ();
281                 }
282
283                 [MonoTODO]
284                 public virtual XmlNode SelectSingleNode (string xpath)
285                 {
286                         throw new NotImplementedException ();
287                 }
288
289                 [MonoTODO]
290                 public virtual XmlNode SelectSingleNode (string xpath, XmlNamespaceManager nsmgr)
291                 {
292                         throw new NotImplementedException ();
293                 }
294
295                 internal void SetParentNode (XmlNode parent)
296                 {
297                         parentNode = parent;
298                 }
299
300                 [MonoTODO]
301                 public virtual bool Supports (string feature, string version)
302                 {
303                         throw new NotImplementedException ();
304                 }
305
306                 [MonoTODO]
307                 public abstract void WriteContentTo (XmlWriter w);
308
309                 [MonoTODO]
310                 public abstract void WriteTo (XmlWriter w);
311
312                 #endregion
313         }
314 }