private void ParseDtdFromParserContext() { Debug.Assert( dtdParserProxy == null && fragmentParserContext != null && fragmentParserContext.HasDtdInfo ); dtdParserProxy = new DtdParserProxy( fragmentParserContext.BaseURI, fragmentParserContext.DocTypeName, fragmentParserContext.PublicId, fragmentParserContext.SystemId, fragmentParserContext.InternalSubset, this ); dtdParserProxy.Parse( false ); SchemaInfo dtdSchemaInfo = dtdParserProxy.DtdSchemaInfo; if ( ( validatingReaderCompatFlag || !v1Compat ) && ( dtdSchemaInfo.HasDefaultAttributes || dtdSchemaInfo.HasNonCDataAttributes ) ) { addDefaultAttributesAndNormalize = true; qName = new XmlQualifiedName(); } }
// Parses DOCTYPE declaration private void ParseDoctypeDecl() { if ( prohibitDtd ) { ThrowWithoutLineInfo( v1Compat ? Res.Xml_DtdIsProhibited : Res.Xml_DtdIsProhibitedEx, string.Empty ); } // parse 'DOCTYPE' while ( ps.charsUsed - ps.charPos < 8 ) { if ( ReadData() == 0 ) { Throw( Res.Xml_UnexpectedEOF, "DOCTYPE" ); } } if ( !XmlConvert.StrEqual( ps.chars, ps.charPos, 7, "DOCTYPE" ) ) { ThrowUnexpectedToken( ( !rootElementParsed && dtdParserProxy == null ) ? "DOCTYPE" : "<!--" ); } if ( !xmlCharType.IsWhiteSpace( ps.chars[ps.charPos + 7] ) ) { Throw( Res.Xml_ExpectingWhiteSpace, ParseUnexpectedToken( ps.charPos + 7 ) ); } if ( dtdParserProxy != null ) { Throw( ps.charPos - 2, Res.Xml_MultipleDTDsProvided ); // position just before <!DOCTYPE } if ( rootElementParsed ) { Throw( ps.charPos - 2, Res.Xml_DtdAfterRootElement ); } ps.charPos += 8; EatWhitespaces( null ); curNode.SetLineInfo( ps.LineNo, ps.LinePos ); // parse DTD dtdParserProxy = new DtdParserProxy( this ); dtdParserProxy.Parse( true ); SchemaInfo dtdSchemaInfo = dtdParserProxy.DtdSchemaInfo; if ( ( validatingReaderCompatFlag || !v1Compat ) && ( dtdSchemaInfo.HasDefaultAttributes || dtdSchemaInfo.HasNonCDataAttributes ) ) { addDefaultAttributesAndNormalize = true; qName = new XmlQualifiedName(); } curNode.SetNamedNode( XmlNodeType.DocumentType, dtdSchemaInfo.DocTypeName.ToString() ); curNode.SetValue( dtdParserProxy.InternalDtdSubset ); nextParsingFunction = parsingFunction; parsingFunction = ParsingFunction.ResetAttributesRootLevel; }