2 // System.Xml.XmlEntity.cs
5 // Duncan Mak (duncan@ximian.com)
6 // Atsushi Enomoto (atsushi@ximian.com)
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:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
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.
36 public class XmlEntity
: XmlNode
40 internal XmlEntity (string name
, string NDATA
, string publicId
, string systemId
,
44 this.name
= doc
.NameTable
.Add (name
);
46 this.publicId
= publicId
;
47 this.systemId
= systemId
;
48 this.baseUri
= doc
.BaseURI
;
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
{
87 public override string Name
{
91 public override XmlNodeType NodeType
{
92 get { return XmlNodeType.Entity; }
95 public string NotationName
{
104 public override string OuterXml
{
105 get { return String.Empty; }
108 public string PublicId
{
110 if (publicId
== null)
117 public string SystemId
{
119 if (publicId
== null)
129 public override XmlNode
CloneNode (bool deep
)
131 throw new InvalidOperationException ("This operation is not supported.");
134 public override void WriteContentTo (XmlWriter w
)
139 public override void WriteTo (XmlWriter w
)
144 internal void SetEntityContent ()
146 if (FirstChild
!= null)
149 XmlDocumentType doctype
= OwnerDocument
.DocumentType
;
154 DTDEntityDeclaration decl
= doctype
.DTD
.EntityDecls
[name
];
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
;
167 XmlNode n
= OwnerDocument
.ReadNode (xmlReader
);
169 InsertBefore (n
, null, false, false);