Exemple #1
0
        private XmlDocumentType LoadDocumentTypeNode()
        {
            Debug.Assert(reader.NodeType == XmlNodeType.DocumentType);

            String publicId       = null;
            String systemId       = null;
            String internalSubset = reader.Value;
            String localName      = reader.LocalName;

            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case "PUBLIC":
                    publicId = reader.Value;
                    break;

                case "SYSTEM":
                    systemId = reader.Value;
                    break;
                }
            }

            XmlDocumentType     dtNode = doc.CreateDocumentType(localName, publicId, systemId, internalSubset);
            XmlValidatingReader vr     = reader as XmlValidatingReader;

            if (vr != null)
            {
                LoadDocumentType(vr, dtNode);
            }
            else
            {
                //construct our own XmlValidatingReader to parse the DocumentType node so we could get Entities and notations information
                XmlTextReader tr = reader as XmlTextReader;
                if (tr != null)
                {
                    dtNode.ParseWithNamespaces = tr.Namespaces;
                    ParseDocumentType(dtNode, true, tr.GetResolver());
                }
                else
                {
                    ParseDocumentType(dtNode);
                }
            }
            return(dtNode);
        }