finish adding stubs to begin work on XmlDocuemnt.Load(file)
[mono.git] / mcs / class / System.XML / System.Xml / XmlAttribute.cs
1 // -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-\r
2 //\r
3 // System.Xml.XmlAttribute\r
4 //\r
5 // Author:\r
6 //   Daniel Weber (daniel-weber@austin.rr.com)\r
7 //\r
8 // (C) 2001 Daniel Weberusing System;\r
9 \r
10 namespace System.Xml\r
11 {\r
12         /// <summary>\r
13         /// Summary description for XmlAttribute.\r
14         /// </summary>\r
15         public class XmlAttribute : XmlNode\r
16         {\r
17                 // ============  private data structures ==============================\r
18                 private  XmlNode FOwner;\r
19                 private XmlNode FOwnerElement;\r
20                 \r
21                 string FelementName;\r
22                 string FattrName;\r
23                 string FattrValue;\r
24                 \r
25                 //==== Public Properties ====================================================\r
26 \r
27 \r
28 \r
29                 /// <summary>\r
30                 /// Saves all children of the current node to the passed writer\r
31                 /// </summary>\r
32                 /// <param name="w"></param>\r
33                 public override void WriteContentTo(XmlWriter w)\r
34                 {\r
35                         // TODO - implement XmlAttribute.WriteContentsTo(XmlWriter)\r
36                         throw new NotImplementedException();\r
37                 }\r
38 \r
39                 /// <summary>\r
40                 /// Saves the current node to writer w\r
41                 /// </summary>\r
42                 /// <param name="w"></param>\r
43                 public override void WriteTo(XmlWriter w)\r
44                 {\r
45                         // TODO - implement XmlAttribute.WriteTo(XmlWriter)\r
46                         throw new NotImplementedException();\r
47                 }\r
48 \r
49                 /// <summary>\r
50                 /// Returns the local name of the attribute.  For attributes, this is the same as Name\r
51                 /// </summary>\r
52                 public override string LocalName \r
53                 {\r
54                         get\r
55                         {\r
56                                 return Name;\r
57                         }\r
58                 }\r
59 \r
60                 /// <summary>\r
61                 /// Get the XmlNode representing the owning document\r
62                 /// </summary>\r
63                 public override XmlDocument OwnerDocument\r
64                 {\r
65                         get\r
66                         {\r
67                                 if (FOwner.NodeType == XmlNodeType.Document)\r
68                                         return FOwner as XmlDocument;\r
69                                 else\r
70                                         return null;\r
71                         }\r
72                 }\r
73 \r
74                 /// <summary>\r
75                 /// Retrieve the XmlElement owner of this attribute, or null if attribute not assigned\r
76                 /// </summary>\r
77                 public virtual XmlElement OwnerElement\r
78                 {\r
79                         get\r
80                         {\r
81                                 if (FOwnerElement.NodeType == XmlNodeType.Element)\r
82                                         return FOwnerElement as XmlElement;\r
83                                 else\r
84                                         return null;\r
85                         }\r
86                 }\r
87                 /// <summary>\r
88                 /// Get the qualified attribute name.  Attributes do not have an associated namespace.\r
89                 /// </summary>\r
90                 public override string Name \r
91                 { \r
92                         get\r
93                         {\r
94                                 return Name;\r
95                         }\r
96                 }\r
97 \r
98                 //============== Public Methods =============================================\r
99                 /// <summary>\r
100                 /// Override.  Returns the node type.\r
101                 /// </summary>\r
102                 public override XmlNodeType NodeType \r
103                 {\r
104                         get\r
105                         {\r
106                                 return XmlNodeType.Attribute;\r
107                         }\r
108                 }\r
109 \r
110                 /// <summary>\r
111                 /// Return a clone of the node\r
112                 /// </summary>\r
113                 /// <param name="deep">Make copy of all children</param>\r
114                 /// <returns>Cloned node</returns>\r
115                 public override XmlNode CloneNode( bool deep)\r
116                 {\r
117                         // TODO - implement XmlAttribute.CloneNode()\r
118                         throw new NotImplementedException();\r
119                 }\r
120 \r
121                 // ============  Internal methods  ====================================\r
122                 internal void setOwnerElement( XmlElement newOwnerElement)\r
123                 {\r
124                         FOwnerElement = newOwnerElement;\r
125                 }\r
126 \r
127                 // ============  Constructors =========================================\r
128                 public XmlAttribute()\r
129                 {\r
130                         //\r
131                         // TODO: Add constructor logic here\r
132                         //\r
133                 }\r
134 \r
135                 internal XmlAttribute ( XmlNode aOwner,                         // owner document\r
136                         string elementName,                                                             // can be ""\r
137                         string attributeName,                                                   // cannot be ""\r
138                         // attType,\r
139                         // defaultDecl,\r
140                         string attValue)                                                                // attValue\r
141                 {\r
142                         if (aOwner == null)\r
143                                 throw new ArgumentException("Null OwnerDocument passed to XmlAttribute constructor");\r
144                         if (attributeName.Length == 0)\r
145                                 throw new ArgumentException("Empty string passed to XmlAttribute constructor");\r
146 \r
147                         FOwner = aOwner;\r
148                         FOwnerElement = null;\r
149                         FelementName = elementName;\r
150                         FattrName = attributeName;\r
151                         FattrValue = attValue;\r
152                 }\r
153         \r
154 \r
155         }\r
156 }\r