2002-12-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
[mono.git] / mcs / class / System.XML / System.Xml / XmlProcessingInstruction.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.Xml.XPath;
12
13 namespace System.Xml
14 {
15         public class XmlProcessingInstruction : XmlLinkedNode
16         {
17                 string target;
18                 string data;
19
20                 #region Constructors
21
22                 protected internal XmlProcessingInstruction (string target, string data, XmlDocument doc) : base(doc)
23                 {
24                         if (data == null)
25                                 data = String.Empty;
26
27                         this.target = target;
28                         this.data = data;
29                 }
30
31                 #endregion
32
33                 #region Properties
34
35                 public string Data
36                 {
37                         get { return data; }
38
39                         set { data = value; }
40                 }
41
42                 public override string InnerText
43                 {
44                         get { return Data; }
45                         set { data = value; }
46                 }
47
48                 public override string LocalName
49                 {
50                         get { return target; }
51                 }
52
53                 public override string Name
54                 {
55                         get { return target; }
56                 }
57
58                 public override XmlNodeType NodeType
59                 {
60                         get { return XmlNodeType.ProcessingInstruction; }
61                 }
62
63                 internal override XPathNodeType XPathNodeType {
64                         get {
65                                 return XPathNodeType.ProcessingInstruction;
66                         }
67                 }
68                 
69                 public string Target
70                 {
71                         get { return target; }
72                 }
73
74                 public override string Value
75                 {
76                         get { return data; }
77                         set {
78                                 if (this.IsReadOnly)
79                                         throw new ArgumentException ("This node is read-only.");
80                                 else
81                                         data = value;
82                         }
83                 }
84
85                 #endregion
86
87                 #region Methods
88
89                 public override XmlNode CloneNode (bool deep)
90                 {
91                         return new XmlProcessingInstruction (target, data, OwnerDocument);
92                 }
93
94                 public override void WriteContentTo (XmlWriter w) { }
95
96                 public override void WriteTo (XmlWriter w)
97                 {
98                         w.WriteProcessingInstruction (target, data);
99                 }
100
101                 #endregion
102         }
103 }