2 // System.Xml.XmlDocumentType.cs
\r
4 // Author: Duncan Mak (duncan@ximian.com)
\r
5 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
\r
10 using System.Collections;
\r
13 namespace System.Xml
\r
15 public class XmlDocumentType : XmlLinkedNode
\r
18 string name; // name of the document type
\r
19 string publicId; // public identifier on the DOCTYPE
\r
20 string systemId; // system identifier on the DOCTYPE
\r
21 string internalSubset; // value of the DTD internal subset
\r
22 internal XmlNamedNodeMap entities;
\r
23 internal XmlNamedNodeMap notations;
\r
27 protected internal XmlDocumentType (string name, string publicId,
\r
28 string systemId, string internalSubset,
\r
33 this.publicId = publicId;
\r
34 this.systemId = systemId;
\r
35 this.internalSubset = internalSubset;
\r
37 XmlTextReader xtr = new XmlTextReader ("", XmlNodeType.Document, null);
\r
38 xtr.GenerateDTDObjectModel (name, publicId, systemId, internalSubset);
\r
44 internal XmlDocumentType (XmlTextReader reader, XmlDocument doc)
\r
47 this.name = reader.Name;
\r
48 this.publicId = reader ["PUBLIC"];
\r
49 this.systemId = reader ["SYSTEM"];
\r
50 this.internalSubset = reader.Value;
\r
51 this.dtd = reader.DTD;
\r
56 private void ImportFromDTD ()
\r
58 entities = new XmlNamedNodeMap (this);
\r
59 notations = new XmlNamedNodeMap (this);
\r
61 foreach (DTDEntityDeclaration decl in DTD.EntityDecls.Values) {
62 XmlNode n = new XmlEntity (decl.Name, decl.NotationName,
63 decl.PublicId, decl.SystemId, OwnerDocument);
64 // FIXME: Value is more complex, similar to Attribute.
65 n.insertBeforeIntern (OwnerDocument.CreateTextNode (decl.EntityValue), null);
66 entities.Nodes.Add (n);
68 foreach (DTDNotationDeclaration decl in DTD.NotationDecls.Values) {
69 XmlNode n = new XmlNotation (decl.LocalName, decl.Prefix,
70 decl.PublicId, decl.SystemId, OwnerDocument);
71 notations.Nodes.Add (n);
76 internal DTDObjectModel DTD {
\r
80 public XmlNamedNodeMap Entities
\r
82 get { return entities; }
\r
85 public string InternalSubset
\r
87 get { return internalSubset; }
\r
90 public override bool IsReadOnly
\r
92 get { return true; } // always return true
\r
95 public override string LocalName
\r
97 get { return name; }
\r
100 public override string Name
\r
102 get { return name; }
\r
105 public override XmlNodeType NodeType
\r
107 get { return XmlNodeType.DocumentType; }
\r
110 public XmlNamedNodeMap Notations
\r
112 get { return notations; }
\r
115 public string PublicId
\r
117 get { return publicId; }
\r
120 public string SystemId
\r
122 get { return systemId; }
\r
126 public override XmlNode CloneNode (bool deep)
\r
129 return new XmlDocumentType (name, publicId, systemId,
\r
130 internalSubset, OwnerDocument);
\r
133 public override void WriteContentTo (XmlWriter w)
\r
138 public override void WriteTo (XmlWriter w)
\r
140 w.WriteDocType (name, publicId, systemId, internalSubset);
\r