2003-10-25 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
[mono.git] / mcs / class / System.XML / System.Xml / XmlDocumentType.cs
index 3447351cb30808ebcf904c3a00f60d015c7536ca..4fd7e87b292933c25e35fedc55b45ff757ce2f0b 100644 (file)
@@ -7,6 +7,7 @@
 // (C) Ximian, Inc.\r
 //\r
 using System;\r
+using System.IO;\r
 using System.Collections;\r
 using Mono.Xml;\r
 \r
@@ -15,13 +16,13 @@ namespace System.Xml
        public class XmlDocumentType  : XmlLinkedNode\r
        {\r
                // Fields\r
-               string name;            // name of the document type\r
-               string publicId;        // public identifier on the DOCTYPE\r
-               string systemId;        // system identifier on the DOCTYPE\r
-               string internalSubset;  // value of the DTD internal subset\r
+//             string name;            // name of the document type\r
+//             string publicId;        // public identifier on the DOCTYPE\r
+//             string systemId;        // system identifier on the DOCTYPE\r
+//             string internalSubset;  // value of the DTD internal subset\r
                internal XmlNamedNodeMap entities;\r
                internal XmlNamedNodeMap notations;\r
-               DTDObjectModel DTD;\r
+               DTDObjectModel dtd;\r
 \r
                // Constructor\r
                protected internal XmlDocumentType (string name, string publicId,\r
@@ -29,27 +30,18 @@ namespace System.Xml
                                                    XmlDocument doc)\r
                        : base (doc)\r
                {\r
-                       this.name = name;\r
-                       this.publicId = publicId;\r
-                       this.systemId = systemId;\r
-                       this.internalSubset = internalSubset;\r
-\r
-                       XmlTextReader xtr = new XmlTextReader ("", XmlNodeType.Document, null);\r
+                       XmlTextReader xtr = new XmlTextReader (BaseURI, new StringReader (""), doc.NameTable);\r
+                       xtr.XmlResolver = doc.Resolver;\r
                        xtr.GenerateDTDObjectModel (name, publicId, systemId, internalSubset);\r
-                       this.DTD = xtr.DTD;\r
+                       this.dtd = xtr.DTD;\r
 \r
                        ImportFromDTD ();\r
                }\r
 \r
-               internal XmlDocumentType (XmlTextReader reader, XmlDocument doc)\r
+               internal XmlDocumentType (DTDObjectModel dtd, XmlDocument doc)\r
                        : base (doc)\r
                {\r
-                       this.name = reader.Name;\r
-                       this.publicId = reader ["PUBLIC"];\r
-                       this.systemId = reader ["SYSTEM"];\r
-                       this.internalSubset = reader.Value;\r
-                       this.DTD = reader.DTD;\r
-\r
+                       this.dtd = dtd;\r
                        ImportFromDTD ();\r
                }\r
 \r
@@ -62,7 +54,7 @@ namespace System.Xml
                                XmlNode n = new XmlEntity (decl.Name, decl.NotationName,
                                        decl.PublicId, decl.SystemId, OwnerDocument);
                                // FIXME: Value is more complex, similar to Attribute.
-                               n.insertBeforeIntern (OwnerDocument.CreateTextNode (decl.EntityValue), null);
+                               n.insertBeforeIntern (OwnerDocument.CreateTextNode (decl.LiteralEntityValue), null);
                                entities.Nodes.Add (n);
                        }
                        foreach (DTDNotationDeclaration decl in DTD.NotationDecls.Values) {
@@ -73,6 +65,10 @@ namespace System.Xml
                }\r
 \r
                // Properties\r
+               internal DTDObjectModel DTD {\r
+                       get { return dtd; }\r
+               }\r
+\r
                public XmlNamedNodeMap Entities\r
                {\r
                        get { return entities; }\r
@@ -80,7 +76,7 @@ namespace System.Xml
                        \r
                public string InternalSubset\r
                {\r
-                       get { return internalSubset; }\r
+                       get { return dtd.InternalSubset; }\r
                }\r
 \r
                public override bool IsReadOnly\r
@@ -90,12 +86,12 @@ namespace System.Xml
 \r
                public override string LocalName\r
                {\r
-                       get { return name; }\r
+                       get { return dtd.Name; }\r
                }\r
 \r
                public override string Name\r
                {\r
-                       get { return name; }\r
+                       get { return dtd.Name; }\r
                }\r
 \r
                public override XmlNodeType NodeType\r
@@ -110,20 +106,21 @@ namespace System.Xml
 \r
                public string PublicId\r
                {\r
-                       get { return publicId; }\r
+                       get { return dtd.PublicId; }\r
                }\r
 \r
                public string SystemId\r
                {\r
-                       get { return systemId; }\r
+                       get { return dtd.SystemId; }\r
                }\r
 \r
                // Methods\r
                public override XmlNode CloneNode (bool deep)\r
                {\r
                        // deep is ignored\r
-                       return new XmlDocumentType (name, publicId, systemId,\r
-                                                   internalSubset, OwnerDocument);\r
+//                     return new XmlDocumentType (Name, PublicId, SystemId,\r
+//                                                 InternalSubset, OwnerDocument);\r
+                       return new XmlDocumentType (dtd, OwnerDocument);\r
                }\r
                \r
                public override void WriteContentTo (XmlWriter w)\r
@@ -133,7 +130,7 @@ namespace System.Xml
 \r
                public override void WriteTo (XmlWriter w)\r
                {\r
-                       w.WriteDocType (name, publicId, systemId, internalSubset);\r
+                       w.WriteDocType (Name, PublicId, SystemId, InternalSubset);\r
                }\r
        }\r
 }\r