(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.XML / System.Xml / XmlEntity.cs
blob114c9f9446881a34d40085acc618dc06c686e71c
1 //
2 // System.Xml.XmlEntity.cs
3 //
4 // Author:
5 // Duncan Mak (duncan@ximian.com)
6 // Atsushi Enomoto (atsushi@ximian.com)
7 //
8 // (C) Ximian, Inc.
9 // (C) 2004 Novell Inc.
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using Mono.Xml;
34 namespace System.Xml
36 public class XmlEntity : XmlNode
38 #region Constructors
40 internal XmlEntity (string name, string NDATA, string publicId, string systemId,
41 XmlDocument doc)
42 : base (doc)
44 this.name = doc.NameTable.Add (name);
45 this.NDATA = NDATA;
46 this.publicId = publicId;
47 this.systemId = systemId;
48 this.baseUri = doc.BaseURI;
51 #endregion
53 #region Fields
55 string name;
56 string NDATA;
57 string publicId;
58 string systemId;
59 string baseUri;
61 #endregion
63 #region Properties
65 public override string BaseURI {
66 get { return baseUri; }
69 public override string InnerText {
70 get { return base.InnerText; }
71 set { throw new InvalidOperationException ("This operation is not supported."); }
74 public override string InnerXml {
75 get { return base.InnerXml; }
76 set { throw new InvalidOperationException ("This operation is not supported."); }
79 public override bool IsReadOnly {
80 get { return true; } // always read-only.
83 public override string LocalName {
84 get { return name; }
87 public override string Name {
88 get { return name; }
91 public override XmlNodeType NodeType {
92 get { return XmlNodeType.Entity; }
95 public string NotationName {
96 get {
97 if (NDATA == null)
98 return null;
99 else
100 return NDATA;
104 public override string OuterXml {
105 get { return String.Empty; }
108 public string PublicId {
109 get {
110 if (publicId == null)
111 return null;
112 else
113 return publicId;
117 public string SystemId {
118 get {
119 if (publicId == null)
120 return null;
121 else
122 return systemId;
125 #endregion
127 #region Methods
129 public override XmlNode CloneNode (bool deep)
131 throw new InvalidOperationException ("This operation is not supported.");
134 public override void WriteContentTo (XmlWriter w)
136 // No effect.
139 public override void WriteTo (XmlWriter w)
141 // No effect.
144 internal void SetEntityContent ()
146 if (FirstChild != null)
147 return;
149 XmlDocumentType doctype = OwnerDocument.DocumentType;
151 if (doctype == null)
152 return;
154 DTDEntityDeclaration decl = doctype.DTD.EntityDecls [name];
155 if (decl == null)
156 return;
158 XmlNameTable nt = this.OwnerDocument.NameTable;
159 XmlNamespaceManager nsmgr = this.ConstructNamespaceManager ();
160 XmlParserContext ctx = new XmlParserContext (OwnerDocument.NameTable, nsmgr,
161 doctype != null ? doctype.DTD : null,
162 BaseURI, XmlLang, XmlSpace, null);
163 XmlTextReader xmlReader = new XmlTextReader (decl.EntityValue, XmlNodeType.Element, ctx);
164 xmlReader.XmlResolver = OwnerDocument.Resolver;
166 do {
167 XmlNode n = OwnerDocument.ReadNode (xmlReader);
168 if(n == null) break;
169 InsertBefore (n, null, false, false);
170 } while (true);
172 SetReadOnly (this);
174 #endregion