2003-02-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.XML / System.Xml / XmlProcessingInstruction.cs
index 582ac99654eae4a079b03c4726beb53864aa982e..089c18965422819567ec83fcb49339b26aea01fe 100644 (file)
@@ -8,6 +8,7 @@
 //
 
 using System;
+using System.Xml.XPath;
 
 namespace System.Xml
 {
@@ -18,8 +19,11 @@ namespace System.Xml
 
                #region Constructors
 
-               protected internal XmlProcessingInstruction(string target, string data, XmlDocument doc) : base(doc)
+               protected internal XmlProcessingInstruction (string target, string data, XmlDocument doc) : base(doc)
                {
+                       if (data == null)
+                               data = String.Empty;
+
                        this.target = target;
                        this.data = data;
                }
@@ -30,47 +34,51 @@ namespace System.Xml
 
                public string Data
                {
-                       get {
-                               return data;
-                       }
+                       get { return data; }
 
-                       set {
-                               data = value;
-                       }
+                       set { data = value; }
+               }
+
+               public override string InnerText
+               {
+                       get { return Data; }
+                       set { data = value; }
                }
 
                public override string LocalName
                {
-                       get {
-                               return target;
-                       }
+                       get { return target; }
                }
 
                public override string Name
                {
-                       get {
-                               return target;
-                       }
+                       get { return target; }
                }
 
                public override XmlNodeType NodeType
                {
+                       get { return XmlNodeType.ProcessingInstruction; }
+               }
+
+               internal override XPathNodeType XPathNodeType {
                        get {
-                               return XmlNodeType.ProcessingInstruction;
+                               return XPathNodeType.ProcessingInstruction;
                        }
                }
                
                public string Target
                {
-                       get {
-                               return target;
-                       }
+                       get { return target; }
                }
 
                public override string Value
                {
-                       get {
-                               return data;
+                       get { return data; }
+                       set {
+                               if (this.IsReadOnly)
+                                       throw new ArgumentException ("This node is read-only.");
+                               else
+                                       data = value;
                        }
                }
 
@@ -78,21 +86,16 @@ namespace System.Xml
 
                #region Methods
 
-               public override XmlNode CloneNode(bool deep)
+               public override XmlNode CloneNode (bool deep)
                {
-                       return new XmlProcessingInstruction(target, data, OwnerDocument);
+                       return new XmlProcessingInstruction (target, data, OwnerDocument);
                }
 
-               [MonoTODO]
-               public override void WriteContentTo(XmlWriter w)
-               {
-                       throw new NotImplementedException ();
-               }
+               public override void WriteContentTo (XmlWriter w) { }
 
-               [MonoTODO]
-               public override void WriteTo(XmlWriter w)
+               public override void WriteTo (XmlWriter w)
                {
-                       throw new NotImplementedException ();
+                       w.WriteProcessingInstruction (target, data);
                }
 
                #endregion