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
36 using XmlTextReaderImpl = Mono.Xml2.XmlTextReader;
\r
38 using XmlTextReaderImpl = System.Xml.XmlTextReader;
\r
41 namespace System.Xml
\r
43 public class XmlDocumentType : XmlLinkedNode
\r
46 internal XmlNamedNodeMap entities;
\r
47 internal XmlNamedNodeMap notations;
\r
51 protected internal XmlDocumentType (string name, string publicId,
\r
52 string systemId, string internalSubset,
\r
56 XmlTextReaderImpl xtr = new XmlTextReaderImpl (BaseURI, new StringReader (""), doc.NameTable);
\r
57 xtr.XmlResolver = doc.Resolver;
\r
58 xtr.GenerateDTDObjectModel (name, publicId, systemId, internalSubset);
\r
64 internal XmlDocumentType (DTDObjectModel dtd, XmlDocument doc)
\r
71 private void ImportFromDTD ()
\r
73 entities = new XmlNamedNodeMap (this);
\r
74 notations = new XmlNamedNodeMap (this);
\r
76 foreach (DTDEntityDeclaration decl in DTD.EntityDecls.Values) {
77 XmlNode n = new XmlEntity (decl.Name, decl.NotationName,
78 decl.PublicId, decl.SystemId, OwnerDocument);
79 entities.SetNamedItem (n);
81 foreach (DTDNotationDeclaration decl in DTD.NotationDecls.Values) {
82 XmlNode n = new XmlNotation (decl.LocalName, decl.Prefix,
83 decl.PublicId, decl.SystemId, OwnerDocument);
84 notations.SetNamedItem (n);
89 internal DTDObjectModel DTD {
\r
93 public XmlNamedNodeMap Entities
\r
95 get { return entities; }
\r
98 public string InternalSubset
\r
100 get { return dtd.InternalSubset; }
\r
103 public override bool IsReadOnly
\r
105 get { return true; } // always return true
\r
108 public override string LocalName
\r
110 get { return dtd.Name; }
\r
113 public override string Name
\r
115 get { return dtd.Name; }
\r
118 public override XmlNodeType NodeType
\r
120 get { return XmlNodeType.DocumentType; }
\r
123 public XmlNamedNodeMap Notations
\r
125 get { return notations; }
\r
128 public string PublicId
\r
130 get { return dtd.PublicId; }
\r
133 public string SystemId
\r
135 get { return dtd.SystemId; }
\r
139 public override XmlNode CloneNode (bool deep)
\r
142 return new XmlDocumentType (dtd, OwnerDocument);
\r
145 public override void WriteContentTo (XmlWriter w)
\r
150 public override void WriteTo (XmlWriter w)
\r
152 w.WriteDocType (Name, PublicId, SystemId, InternalSubset);
\r