// System.Xml.XmlDocumentType.cs\r
//\r
// Author: Duncan Mak (duncan@ximian.com)\r
+// Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)\r
//\r
// (C) Ximian, Inc.\r
//\r
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;\r
+using System.IO;\r
+using System.Collections;\r
+using Mono.Xml;\r
+\r
+#if NET_2_0\r
+using XmlTextReaderImpl = Mono.Xml2.XmlTextReader;\r
+#else\r
+using XmlTextReaderImpl = System.Xml.XmlTextReader;\r
+#endif\r
\r
namespace System.Xml\r
{\r
- public class XmlDocumentType : XmlLinkedNode\r
+ 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
- XmlDocument document;\r
- \r
- // Constructor \r
- protected internal XmlDocumentType (string name, string publicId, string systemId,\r
- string internalSubset, XmlDocument doc)\r
- : base () \r
+ internal XmlNamedNodeMap entities;\r
+ internal XmlNamedNodeMap notations;\r
+ DTDObjectModel dtd;\r
+\r
+ // Constructor\r
+ protected internal XmlDocumentType (string name, string publicId,\r
+ string systemId, string internalSubset,\r
+ XmlDocument doc)\r
+ : base (doc)\r
+ {\r
+ XmlTextReaderImpl xtr = new XmlTextReaderImpl (BaseURI, new StringReader (""), doc.NameTable);\r
+ xtr.XmlResolver = doc.Resolver;\r
+ xtr.GenerateDTDObjectModel (name, publicId, systemId, internalSubset);\r
+ this.dtd = xtr.DTD;\r
+\r
+ ImportFromDTD ();\r
+ }\r
+\r
+ internal XmlDocumentType (DTDObjectModel dtd, XmlDocument doc)\r
+ : base (doc)\r
{\r
- this.name = name;\r
- this.publicId = publicId;\r
- this.systemId = systemId;\r
- this.internalSubset = internalSubset;\r
- this.document = doc;\r
+ this.dtd = dtd;\r
+ ImportFromDTD ();\r
}\r
\r
+ private void ImportFromDTD ()\r
+ {\r
+ entities = new XmlNamedNodeMap (this);\r
+ notations = new XmlNamedNodeMap (this);\r
+\r
+ foreach (DTDEntityDeclaration decl in DTD.EntityDecls.Values) {
+ XmlNode n = new XmlEntity (decl.Name, decl.NotationName,
+ decl.PublicId, decl.SystemId, OwnerDocument);
+ entities.SetNamedItem (n);
+ }
+ foreach (DTDNotationDeclaration decl in DTD.NotationDecls.Values) {
+ XmlNode n = new XmlNotation (decl.LocalName, decl.Prefix,
+ decl.PublicId, decl.SystemId, OwnerDocument);
+ notations.SetNamedItem (n);
+ }
+ }\r
\r
// Properties\r
- [MonoTODO]\r
+ internal DTDObjectModel DTD {\r
+ get { return dtd; }\r
+ }\r
+\r
public XmlNamedNodeMap Entities\r
{\r
- get { return null; }\r
+ get { return entities; }\r
}\r
\r
public string InternalSubset\r
{\r
- get { return internalSubset; }\r
+ get { return dtd.InternalSubset; }\r
}\r
\r
public override bool IsReadOnly\r
\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
get { return XmlNodeType.DocumentType; }\r
}\r
\r
- [MonoTODO]\r
public XmlNamedNodeMap Notations\r
{\r
- get { return null; }\r
+ get { return notations; }\r
}\r
\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
- [MonoTODO]\r
public override XmlNode CloneNode (bool deep)\r
{\r
- return null;\r
+ // deep is ignored\r
+ return new XmlDocumentType (dtd, OwnerDocument);\r
}\r
-\r
- [MonoTODO]\r
+ \r
public override void WriteContentTo (XmlWriter w)\r
{\r
+ // No effect\r
}\r
\r
- [MonoTODO]\r
public override void WriteTo (XmlWriter w)\r
{\r
+ w.WriteDocType (Name, PublicId, SystemId, InternalSubset);\r
}\r
}\r
}\r