Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Xml / System / Xml / Dom / XmlDocumentType.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="XmlDocumentType.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
7
8 namespace System.Xml {
9
10     using System.Xml.Schema;
11     using System.Diagnostics;
12
13     // Contains information associated with the document type declaration.
14     public class XmlDocumentType : XmlLinkedNode {
15         string name;
16         string publicId;
17         string systemId;
18         string internalSubset;
19         bool namespaces;
20         XmlNamedNodeMap entities;
21         XmlNamedNodeMap notations;
22
23         // parsed DTD
24         SchemaInfo schemaInfo;
25
26         protected internal XmlDocumentType( string name, string publicId, string systemId, string internalSubset, XmlDocument doc ) : base( doc ) {
27             this.name     = name;
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 ) {
34                 doc.IsLoading = true;
35                 XmlLoader loader = new XmlLoader();
36                 loader.ParseDocumentType( this ); //will edit notation nodes, etc.
37                 doc.IsLoading = false;
38             }
39         }
40
41         // Gets the name of the node.
42         public override string Name {
43             get { return name;}
44         }
45
46         // Gets the name of the current node without the namespace prefix.
47         public override string LocalName {
48             get { return name;}
49         }
50
51         // Gets the type of the current node.
52         public override XmlNodeType NodeType {
53             get { return XmlNodeType.DocumentType;}
54         }
55
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 );
60         }
61
62         // 
63         // Microsoft extensions
64         //
65
66         //  Gets a value indicating whether the node is read-only.
67         public override bool IsReadOnly {
68             get { 
69                 return true;        // Make entities and notations readonly
70             }
71         }
72
73         // Gets the collection of XmlEntity nodes declared in the document type declaration.
74         public XmlNamedNodeMap Entities { 
75             get { 
76                 if (entities == null)
77                     entities = new XmlNamedNodeMap( this );
78
79                 return entities;
80             }
81         }
82
83         // Gets the collection of XmlNotation nodes present in the document type declaration.
84         public XmlNamedNodeMap Notations { 
85             get {
86                 if (notations == null)
87                     notations = new XmlNamedNodeMap( this );
88
89                 return notations;
90             }
91         }
92
93         //
94         // DOM Level 2
95         //
96
97         // Gets the value of the public identifier on the DOCTYPE declaration.
98         public string PublicId { 
99             get { return publicId;} 
100         }
101
102         // Gets the value of
103         // the system identifier on the DOCTYPE declaration.
104         public string SystemId { 
105             get { return systemId;} 
106         }
107
108         // Gets the entire value of the DTD internal subset
109         // on the DOCTYPE declaration.
110         public string InternalSubset { 
111             get { return internalSubset;}
112         }
113
114         internal bool ParseWithNamespaces {
115             get { return namespaces; }
116             set { namespaces = value; }
117         }
118
119         // Saves the node to the specified XmlWriter.
120         public override void WriteTo(XmlWriter w) {
121             w.WriteDocType( name, publicId, systemId, internalSubset );
122         }
123
124         // Saves all the children of the node to the specified XmlWriter.
125         public override void WriteContentTo(XmlWriter w) {
126             // Intentionally do nothing
127         }
128
129         internal SchemaInfo DtdSchemaInfo {
130             get {
131                 return schemaInfo;
132             }
133             set {
134                 schemaInfo = value;
135             }
136         }
137     }
138 }