1 //------------------------------------------------------------------------------
2 // <copyright file="XmlDocumentType.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
10 using System.Xml.Schema;
11 using System.Diagnostics;
13 // Contains information associated with the document type declaration.
14 public class XmlDocumentType : XmlLinkedNode {
18 string internalSubset;
20 XmlNamedNodeMap entities;
21 XmlNamedNodeMap notations;
24 SchemaInfo schemaInfo;
26 protected internal XmlDocumentType( string name, string publicId, string systemId, string internalSubset, XmlDocument doc ) : base( doc ) {
28 this.publicId = publicId;
29 this.systemId = systemId;
30 this.namespaces = true;
31 this.internalSubset = internalSubset;
32 Debug.Assert( doc != null );
33 if ( !doc.IsLoading ) {
35 XmlLoader loader = new XmlLoader();
36 loader.ParseDocumentType( this ); //will edit notation nodes, etc.
37 doc.IsLoading = false;
41 // Gets the name of the node.
42 public override string Name {
46 // Gets the name of the current node without the namespace prefix.
47 public override string LocalName {
51 // Gets the type of the current node.
52 public override XmlNodeType NodeType {
53 get { return XmlNodeType.DocumentType;}
56 // Creates a duplicate of this node.
57 public override XmlNode CloneNode(bool deep) {
58 Debug.Assert( OwnerDocument != null );
59 return OwnerDocument.CreateDocumentType( name, publicId, systemId, internalSubset );
63 // Microsoft extensions
66 // Gets a value indicating whether the node is read-only.
67 public override bool IsReadOnly {
69 return true; // Make entities and notations readonly
73 // Gets the collection of XmlEntity nodes declared in the document type declaration.
74 public XmlNamedNodeMap Entities {
77 entities = new XmlNamedNodeMap( this );
83 // Gets the collection of XmlNotation nodes present in the document type declaration.
84 public XmlNamedNodeMap Notations {
86 if (notations == null)
87 notations = new XmlNamedNodeMap( this );
97 // Gets the value of the public identifier on the DOCTYPE declaration.
98 public string PublicId {
99 get { return publicId;}
103 // the system identifier on the DOCTYPE declaration.
104 public string SystemId {
105 get { return systemId;}
108 // Gets the entire value of the DTD internal subset
109 // on the DOCTYPE declaration.
110 public string InternalSubset {
111 get { return internalSubset;}
114 internal bool ParseWithNamespaces {
115 get { return namespaces; }
116 set { namespaces = value; }
119 // Saves the node to the specified XmlWriter.
120 public override void WriteTo(XmlWriter w) {
121 w.WriteDocType( name, publicId, systemId, internalSubset );
124 // Saves all the children of the node to the specified XmlWriter.
125 public override void WriteContentTo(XmlWriter w) {
126 // Intentionally do nothing
129 internal SchemaInfo DtdSchemaInfo {