2002-03-11 Duncan Mak <duncan@ximian.com>
[mono.git] / mcs / class / System.XML / System.Xml / XmlElement.cs
1 //
2 // System.Xml.XmlAttribute
3 //
4 // Author:
5 //   Jason Diamond (jason@injektilo.org)
6 //
7 // (C) 2002 Jason Diamond  http://injektilo.org/
8 //
9
10 using System;
11
12 namespace System.Xml
13 {
14         public class XmlElement : XmlLinkedNode
15         {
16                 #region Fields
17
18                 private XmlAttributeCollection attributes;
19                 private XmlLinkedNode lastLinkedChild;
20                 private string localName;
21                 private string namespaceURI;
22                 private string prefix;
23
24                 #endregion
25
26                 #region Constructor
27
28                 protected internal XmlElement (
29                         string prefix, 
30                         string localName, 
31                         string namespaceURI, 
32                         XmlDocument doc) : base (doc)
33                 {
34                         this.prefix = prefix;
35                         this.localName = localName;
36                         this.namespaceURI = namespaceURI;
37
38                         attributes = new XmlAttributeCollection (this);
39                 }
40
41                 #endregion
42
43                 #region Properties
44
45                 public override XmlAttributeCollection Attributes {
46                         get { 
47                                 return attributes; 
48                         }
49                 }
50
51                 public virtual bool HasAttributes {
52                         get { 
53                                 return attributes.Count > 0; 
54                         }
55                 }
56
57                 [MonoTODO]
58                 public override string InnerText {
59                         get { 
60                                 throw new NotImplementedException (); 
61                         }
62
63                         set { 
64                                 throw new NotImplementedException (); 
65                         }
66                 }
67
68                 [MonoTODO]
69                 public override string InnerXml {
70                         get { 
71                                 throw new NotImplementedException (); 
72                         }
73
74                         set { 
75                                 throw new NotImplementedException (); 
76                         }
77                 }
78
79                 [MonoTODO]
80                 public bool IsEmpty     {
81                         get { 
82                                 throw new NotImplementedException (); 
83                         }
84
85                         set { 
86                                 throw new NotImplementedException (); 
87                         }
88                 }
89
90                 internal override XmlLinkedNode LastLinkedChild {
91                         get     {
92                                 return lastLinkedChild;
93                         }
94
95                         set {
96                                 lastLinkedChild = value;
97                         }
98                 }
99                 
100                 public override string LocalName 
101                 {
102                         get { 
103                                 return localName; 
104                         }
105                 }
106
107                 public override string Name {
108                         get { 
109                                 return prefix != String.Empty ? prefix + ":" + localName : localName; 
110                         }
111                 }
112
113                 public override string NamespaceURI {
114                         get { 
115                                 return namespaceURI; 
116                         }
117                 }
118
119                 [MonoTODO]
120                 public override XmlNode NextSibling {
121                         get { 
122                                 return base.NextSibling; 
123                         }
124                 }
125
126                 public override XmlNodeType NodeType {
127                         get { 
128                                 return XmlNodeType.Element; 
129                         }
130                 }
131
132                 [MonoTODO]
133                 public override XmlDocument OwnerDocument {
134                         get { 
135                                 return base.OwnerDocument; 
136                         }
137                 }
138
139                 public override string Prefix {
140                         get { 
141                                 return prefix; 
142                         }
143                 }
144
145                 #endregion
146
147                 #region Methods
148
149                 [MonoTODO]
150                 public override XmlNode CloneNode (bool deep)
151                 {
152                         throw new NotImplementedException ();
153                 }
154
155                 [MonoTODO]
156                 public virtual string GetAttribute (string name)
157                 {
158                         XmlNode attributeNode = Attributes.GetNamedItem (name);
159                         return attributeNode != null ? attributeNode.Value : String.Empty;
160                 }
161
162                 [MonoTODO]
163                 public virtual string GetAttribute (string localName, string namespaceURI)
164                 {
165                         throw new NotImplementedException ();
166                 }
167
168                 [MonoTODO]
169                 public virtual XmlAttribute GetAttributeNode (string name)
170                 {
171                         throw new NotImplementedException ();
172                 }
173
174                 [MonoTODO]
175                 public virtual XmlAttribute GetAttributeNode (string localName, string namespaceURI)
176                 {
177                         throw new NotImplementedException ();
178                 }
179
180                 [MonoTODO]
181                 public virtual XmlNodeList GetElementsByTagName (string name)
182                 {
183                         throw new NotImplementedException ();
184                 }
185
186                 [MonoTODO]
187                 public virtual XmlNodeList GetElementsByTagName (string localName, string namespaceURI)
188                 {
189                         throw new NotImplementedException ();
190                 }
191
192                 [MonoTODO]
193                 public virtual bool HasAttribute (string name)
194                 {
195                         throw new NotImplementedException ();
196                 }
197
198                 [MonoTODO]
199                 public virtual bool HasAttribute (string localName, string namespaceURI)
200                 {
201                         throw new NotImplementedException ();
202                 }
203
204                 [MonoTODO ("Don't remove default attributes.")]
205                 public override void RemoveAll ()
206                 {
207                         // Remove the child nodes.
208                         base.RemoveAll ();
209
210                         // Remove all attributes.
211                         attributes.RemoveAll ();
212                 }
213
214                 [MonoTODO]
215                 public virtual void RemoveAllAttributes ()
216                 {
217                         throw new NotImplementedException ();
218                 }
219
220                 [MonoTODO]
221                 public virtual void RemoveAttribute (string name)
222                 {
223                         throw new NotImplementedException ();
224                 }
225
226                 [MonoTODO]
227                 public virtual void RemoveAttribute (string localName, string namespaceURI)
228                 {
229                         throw new NotImplementedException ();
230                 }
231
232                 [MonoTODO]
233                 public virtual XmlNode RemoveAttributeAt (int i)
234                 {
235                         throw new NotImplementedException ();
236                 }
237
238                 [MonoTODO]
239                 public virtual XmlAttribute RemoveAttributeNode (XmlAttribute oldAttr)
240                 {
241                         throw new NotImplementedException ();
242                 }
243
244                 [MonoTODO]
245                 public virtual XmlAttribute RemoveAttributeNode (string localName, string namespaceURI)
246                 {
247                         throw new NotImplementedException ();
248                 }
249
250                 [MonoTODO]
251                 public virtual void SetAttribute (string name, string value)
252                 {
253                         XmlAttribute attribute = OwnerDocument.CreateAttribute (name);
254                         attribute.SetOwnerElement (this);
255                         attribute.Value = value;
256                         Attributes.SetNamedItem (attribute);
257                 }
258
259                 [MonoTODO]
260                 public virtual void SetAttribute (string localName, string namespaceURI, string value)
261                 {
262                         throw new NotImplementedException ();
263                 }
264
265                 [MonoTODO]
266                 public virtual XmlAttribute SetAttributeNode (XmlAttribute newAttr)
267                 {
268                         throw new NotImplementedException ();
269                 }
270
271                 [MonoTODO]
272                 public virtual XmlAttribute SetAttributeNode (string localName, string namespaceURI)
273                 {
274                         throw new NotImplementedException ();
275                 }
276
277                 [MonoTODO]
278                 public override void WriteContentTo (XmlWriter w)
279                 {
280                         throw new NotImplementedException ();
281                 }
282
283                 [MonoTODO]
284                 public override void WriteTo (XmlWriter w)
285                 {
286                         throw new NotImplementedException ();
287                 }
288
289                 #endregion
290         }
291 }