2 // System.Xml.XmlDocumentType.cs
\r
4 // Author: Duncan Mak (duncan@ximian.com)
\r
5 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
\r
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Collections;
\r
35 namespace System.Xml
\r
37 public class XmlDocumentType : XmlLinkedNode
\r
40 internal XmlNamedNodeMap entities;
\r
41 internal XmlNamedNodeMap notations;
\r
45 protected internal XmlDocumentType (string name, string publicId,
\r
46 string systemId, string internalSubset,
\r
50 XmlTextReader xtr = new XmlTextReader (BaseURI, new StringReader (""), doc.NameTable);
\r
51 xtr.XmlResolver = doc.Resolver;
\r
52 xtr.GenerateDTDObjectModel (name, publicId, systemId, internalSubset);
\r
58 internal XmlDocumentType (DTDObjectModel dtd, XmlDocument doc)
\r
65 private void ImportFromDTD ()
\r
67 entities = new XmlNamedNodeMap (this);
\r
68 notations = new XmlNamedNodeMap (this);
\r
70 foreach (DTDEntityDeclaration decl in DTD.EntityDecls.Values) {
71 XmlNode n = new XmlEntity (decl.Name, decl.NotationName,
72 decl.PublicId, decl.SystemId, OwnerDocument);
73 entities.SetNamedItem (n);
75 foreach (DTDNotationDeclaration decl in DTD.NotationDecls.Values) {
76 XmlNode n = new XmlNotation (decl.LocalName, decl.Prefix,
77 decl.PublicId, decl.SystemId, OwnerDocument);
78 notations.SetNamedItem (n);
83 internal DTDObjectModel DTD {
\r
87 public XmlNamedNodeMap Entities
\r
89 get { return entities; }
\r
92 public string InternalSubset
\r
94 get { return dtd.InternalSubset; }
\r
97 public override bool IsReadOnly
\r
99 get { return true; } // always return true
\r
102 public override string LocalName
\r
104 get { return dtd.Name; }
\r
107 public override string Name
\r
109 get { return dtd.Name; }
\r
112 public override XmlNodeType NodeType
\r
114 get { return XmlNodeType.DocumentType; }
\r
117 public XmlNamedNodeMap Notations
\r
119 get { return notations; }
\r
122 public string PublicId
\r
124 get { return dtd.PublicId; }
\r
127 public string SystemId
\r
129 get { return dtd.SystemId; }
\r
133 public override XmlNode CloneNode (bool deep)
\r
136 return new XmlDocumentType (dtd, OwnerDocument);
\r
139 public override void WriteContentTo (XmlWriter w)
\r
144 public override void WriteTo (XmlWriter w)
\r
146 w.WriteDocType (Name, PublicId, SystemId, InternalSubset);
\r