Ejemplo n.º 1
0
 private void ParseDtdFromParserContext()
 {
     if ((this.parserContext.DocTypeName != null) && (this.parserContext.DocTypeName.Length != 0))
     {
         IDtdParser parser = DtdParser.Create();
         XmlTextReaderImpl.DtdParserProxy adapter = new XmlTextReaderImpl.DtdParserProxy(this.coreReaderImpl);
         IDtdInfo newDtdInfo = parser.ParseFreeFloatingDtd(this.parserContext.BaseURI, this.parserContext.DocTypeName, this.parserContext.PublicId, this.parserContext.SystemId, this.parserContext.InternalSubset, adapter);
         this.coreReaderImpl.SetDtdInfo(newDtdInfo);
         this.ValidateDtd();
     }
 }
Ejemplo n.º 2
0
#pragma warning disable 618
        // Creates a XmlValidatingReader suitable for parsing InnerXml strings
        private XmlReader CreateInnerXmlReader(String xmlFragment, XmlNodeType nt, XmlParserContext context, XmlDocument doc)
        {
            XmlNodeType contentNT = nt;

            if (contentNT == XmlNodeType.Entity || contentNT == XmlNodeType.EntityReference)
            {
                contentNT = XmlNodeType.Element;
            }

            XmlTextReaderImpl tr = new XmlTextReaderImpl(xmlFragment, contentNT, context);

            tr.XmlValidatingReaderCompatibilityMode = true;
            if (doc.HasSetResolver)
            {
                tr.XmlResolver = doc.GetResolver();
            }
            if (!(doc.ActualLoadingStatus))
            {
                tr.DisableUndeclaredEntityCheck = true;
            }
            Debug.Assert(tr.EntityHandling == EntityHandling.ExpandCharEntities);

            XmlDocumentType dtdNode = doc.DocumentType;

            if (dtdNode != null)
            {
                tr.Namespaces = dtdNode.ParseWithNamespaces;
                if (dtdNode.DtdSchemaInfo != null)
                {
                    tr.SetDtdInfo(dtdNode.DtdSchemaInfo);
                }
                else
                {
                    IDtdParser dtdParser = DtdParser.Create();
                    XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(tr);

                    IDtdInfo dtdInfo = dtdParser.ParseFreeFloatingDtd(context.BaseURI, context.DocTypeName, context.PublicId, context.SystemId, context.InternalSubset, proxy);

                    // TODO: Change all of XmlDocument to IDtdInfo interfaces
                    dtdNode.DtdSchemaInfo = dtdInfo as SchemaInfo;
                    tr.SetDtdInfo(dtdInfo);
                }
            }

            if (nt == XmlNodeType.Entity || nt == XmlNodeType.EntityReference)
            {
                tr.Read(); //this will skip the first element "wrapper"
                tr.ResolveEntity();
            }
            return(tr);
        }
Ejemplo n.º 3
0
        private XmlReader CreateInnerXmlReader(string xmlFragment, XmlNodeType nt, XmlParserContext context, XmlDocument doc)
        {
            XmlNodeType fragType = nt;

            switch (fragType)
            {
            case XmlNodeType.Entity:
            case XmlNodeType.EntityReference:
                fragType = XmlNodeType.Element;
                break;
            }
            XmlTextReaderImpl reader = new XmlTextReaderImpl(xmlFragment, fragType, context)
            {
                XmlValidatingReaderCompatibilityMode = true
            };

            if (doc.HasSetResolver)
            {
                reader.XmlResolver = doc.GetResolver();
            }
            if (!doc.ActualLoadingStatus)
            {
                reader.DisableUndeclaredEntityCheck = true;
            }
            XmlDocumentType documentType = doc.DocumentType;

            if (documentType != null)
            {
                reader.Namespaces = documentType.ParseWithNamespaces;
                if (documentType.DtdSchemaInfo != null)
                {
                    reader.SetDtdInfo(documentType.DtdSchemaInfo);
                }
                else
                {
                    IDtdParser parser = DtdParser.Create();
                    XmlTextReaderImpl.DtdParserProxy adapter = new XmlTextReaderImpl.DtdParserProxy(reader);
                    IDtdInfo newDtdInfo = parser.ParseFreeFloatingDtd(context.BaseURI, context.DocTypeName, context.PublicId, context.SystemId, context.InternalSubset, adapter);
                    documentType.DtdSchemaInfo = newDtdInfo as SchemaInfo;
                    reader.SetDtdInfo(newDtdInfo);
                }
            }
            if ((nt == XmlNodeType.Entity) || (nt == XmlNodeType.EntityReference))
            {
                reader.Read();
                reader.ResolveEntity();
            }
            return(reader);
        }
 private XmlReader CreateInnerXmlReader(string xmlFragment, XmlNodeType nt, XmlParserContext context, XmlDocument doc)
 {
     XmlNodeType fragType = nt;
     switch (fragType)
     {
         case XmlNodeType.Entity:
         case XmlNodeType.EntityReference:
             fragType = XmlNodeType.Element;
             break;
     }
     XmlTextReaderImpl reader = new XmlTextReaderImpl(xmlFragment, fragType, context) {
         XmlValidatingReaderCompatibilityMode = true
     };
     if (doc.HasSetResolver)
     {
         reader.XmlResolver = doc.GetResolver();
     }
     if (!doc.ActualLoadingStatus)
     {
         reader.DisableUndeclaredEntityCheck = true;
     }
     XmlDocumentType documentType = doc.DocumentType;
     if (documentType != null)
     {
         reader.Namespaces = documentType.ParseWithNamespaces;
         if (documentType.DtdSchemaInfo != null)
         {
             reader.SetDtdInfo(documentType.DtdSchemaInfo);
         }
         else
         {
             IDtdParser parser = DtdParser.Create();
             XmlTextReaderImpl.DtdParserProxy adapter = new XmlTextReaderImpl.DtdParserProxy(reader);
             IDtdInfo newDtdInfo = parser.ParseFreeFloatingDtd(context.BaseURI, context.DocTypeName, context.PublicId, context.SystemId, context.InternalSubset, adapter);
             documentType.DtdSchemaInfo = newDtdInfo as SchemaInfo;
             reader.SetDtdInfo(newDtdInfo);
         }
     }
     if ((nt == XmlNodeType.Entity) || (nt == XmlNodeType.EntityReference))
     {
         reader.Read();
         reader.ResolveEntity();
     }
     return reader;
 }
        //
        // Private implementation methods
        //

        private async Task ParseDtdFromParserContextAsync()
        {
            Debug.Assert(_parserContext != null);
            Debug.Assert(_coreReaderImpl.DtdInfo == null);

            if (_parserContext.DocTypeName == null || _parserContext.DocTypeName.Length == 0)
            {
                return;
            }

            IDtdParser dtdParser = DtdParser.Create();

            XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(_coreReaderImpl);
            IDtdInfo dtdInfo = await dtdParser.ParseFreeFloatingDtdAsync(_parserContext.BaseURI, _parserContext.DocTypeName, _parserContext.PublicId, _parserContext.SystemId, _parserContext.InternalSubset, proxy).ConfigureAwait(false);

            _coreReaderImpl.SetDtdInfo(dtdInfo);

            ValidateDtd();
        }
Ejemplo n.º 6
0
        private void ParseDocumentType(XmlDocumentType dtNode, bool bUseResolver, XmlResolver resolver)
        {
            _doc = dtNode.OwnerDocument;
            XmlParserContext  pc = new XmlParserContext(null, new XmlNamespaceManager(_doc.NameTable), null, null, null, null, _doc.BaseURI, string.Empty, XmlSpace.None);
            XmlTextReaderImpl tr = new XmlTextReaderImpl("", XmlNodeType.Element, pc);

            tr.Namespaces = dtNode.ParseWithNamespaces;
            if (bUseResolver)
            {
                tr.XmlResolver = resolver;
            }

            IDtdParser dtdParser = DtdParser.Create();

            XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(tr);

            IDtdInfo dtdInfo = dtdParser.ParseFreeFloatingDtd(_doc.BaseURI, dtNode.Name, dtNode.PublicId, dtNode.SystemId, dtNode.InternalSubset, proxy);

            LoadDocumentType(dtdInfo, dtNode);
        }
//
// Private implementation methods
//

        private void ParseDtdFromParserContext()
        {
            Debug.Assert(parserContext != null);
            Debug.Assert(coreReaderImpl.DtdInfo == null);

            if (parserContext.DocTypeName == null || parserContext.DocTypeName.Length == 0)
            {
                return;
            }

            IDtdParser dtdParser = DtdParser.Create();

            XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(coreReaderImpl);
            IDtdInfo dtdInfo = dtdParser.ParseFreeFloatingDtd(parserContext.BaseURI, parserContext.DocTypeName, parserContext.PublicId,
                                                              parserContext.SystemId, parserContext.InternalSubset, proxy);

            coreReaderImpl.SetDtdInfo(dtdInfo);

            ValidateDtd();
        }
Ejemplo n.º 8
0
        private void ParseDocumentType(XmlDocumentType dtNode, bool bUseResolver, XmlResolver resolver)
        {
            this.doc = dtNode.OwnerDocument;
            XmlParserContext  context = new XmlParserContext(null, new XmlNamespaceManager(this.doc.NameTable), null, null, null, null, this.doc.BaseURI, string.Empty, XmlSpace.None);
            XmlTextReaderImpl reader  = new XmlTextReaderImpl("", XmlNodeType.Element, context)
            {
                Namespaces = dtNode.ParseWithNamespaces
            };

            if (bUseResolver)
            {
                reader.XmlResolver = resolver;
            }
            IDtdParser parser = DtdParser.Create();

            XmlTextReaderImpl.DtdParserProxy adapter = new XmlTextReaderImpl.DtdParserProxy(reader);
            IDtdInfo dtdInfo = parser.ParseFreeFloatingDtd(this.doc.BaseURI, dtNode.Name, dtNode.PublicId, dtNode.SystemId, dtNode.InternalSubset, adapter);

            this.LoadDocumentType(dtdInfo, dtNode);
        }
//
// Private implementation methods
//

        private void ParseDtdFromParserContext()
        {
            Debug.Assert( parserContext != null );
            Debug.Assert( coreReaderImpl.DtdInfo == null );

            if ( parserContext.DocTypeName == null || parserContext.DocTypeName.Length == 0 ) {
                return;
            }

            IDtdParser dtdParser = DtdParser.Create();
            XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(coreReaderImpl);
            IDtdInfo dtdInfo = dtdParser.ParseFreeFloatingDtd( parserContext.BaseURI, parserContext.DocTypeName, parserContext.PublicId, 
                                                              parserContext.SystemId, parserContext.InternalSubset, proxy );
            coreReaderImpl.SetDtdInfo( dtdInfo);

            ValidateDtd();
        }
Ejemplo n.º 10
0
 static internal SchemaInfo Parse( XmlTextReaderImpl tr, string baseUri, string docTypeName, string publicId, string systemId, string internalSubset ) {
     XmlTextReaderImpl.DtdParserProxy dtdParserProxy = new XmlTextReaderImpl.DtdParserProxy( baseUri, docTypeName, publicId, systemId, internalSubset, tr ); 
     dtdParserProxy.Parse( false );
     return dtdParserProxy.DtdSchemaInfo;
 }
Ejemplo n.º 11
0
#pragma warning disable 618
        // Creates a XmlValidatingReader suitable for parsing InnerXml strings
        private XmlReader CreateInnerXmlReader(String xmlFragment, XmlNodeType nt, XmlParserContext context, XmlDocument doc)
        {
            XmlNodeType contentNT = nt;
            if (contentNT == XmlNodeType.Entity || contentNT == XmlNodeType.EntityReference)
                contentNT = XmlNodeType.Element;

            XmlTextReaderImpl tr = new XmlTextReaderImpl(xmlFragment, contentNT, context);
            tr.XmlValidatingReaderCompatibilityMode = true;
            if (doc.HasSetResolver)
            {
                tr.XmlResolver = doc.GetResolver();
            }
            if (!(doc.ActualLoadingStatus))
            {
                tr.DisableUndeclaredEntityCheck = true;
            }
            Debug.Assert(tr.EntityHandling == EntityHandling.ExpandCharEntities);

            XmlDocumentType dtdNode = doc.DocumentType;
            if (dtdNode != null)
            {
                tr.Namespaces = dtdNode.ParseWithNamespaces;
                if (dtdNode.DtdSchemaInfo != null)
                {
                    tr.SetDtdInfo(dtdNode.DtdSchemaInfo);
                }
                else
                {
                    IDtdParser dtdParser = DtdParser.Create();
                    XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(tr);

                    IDtdInfo dtdInfo = dtdParser.ParseFreeFloatingDtd(context.BaseURI, context.DocTypeName, context.PublicId, context.SystemId, context.InternalSubset, proxy);

                    // TODO: Change all of XmlDocument to IDtdInfo interfaces
                    dtdNode.DtdSchemaInfo = dtdInfo as SchemaInfo;
                    tr.SetDtdInfo(dtdInfo);
                }
            }

            if (nt == XmlNodeType.Entity || nt == XmlNodeType.EntityReference)
            {
                tr.Read(); //this will skip the first element "wrapper"
                tr.ResolveEntity();
            }
            return tr;
        }
Ejemplo n.º 12
0
        private void ParseDocumentType(XmlDocumentType dtNode, bool bUseResolver, XmlResolver resolver)
        {
            _doc = dtNode.OwnerDocument;
            XmlParserContext pc = new XmlParserContext(null, new XmlNamespaceManager(_doc.NameTable), null, null, null, null, _doc.BaseURI, string.Empty, XmlSpace.None);
            XmlTextReaderImpl tr = new XmlTextReaderImpl("", XmlNodeType.Element, pc);
            tr.Namespaces = dtNode.ParseWithNamespaces;
            if (bUseResolver)
            {
                tr.XmlResolver = resolver;
            }

            IDtdParser dtdParser = DtdParser.Create();
            XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(tr);

            IDtdInfo dtdInfo = dtdParser.ParseFreeFloatingDtd(_doc.BaseURI, dtNode.Name, dtNode.PublicId, dtNode.SystemId, dtNode.InternalSubset, proxy);
            LoadDocumentType(dtdInfo, dtNode);
        }
Ejemplo n.º 13
0
        //
        // Private implementation methods
        //

        private async Task ParseDtdFromParserContextAsync()
        {
            Debug.Assert(_parserContext != null);
            Debug.Assert(_coreReaderImpl.DtdInfo == null);

            if (_parserContext.DocTypeName == null || _parserContext.DocTypeName.Length == 0)
            {
                return;
            }

            IDtdParser dtdParser = DtdParser.Create();
            XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(_coreReaderImpl);
            IDtdInfo dtdInfo = await dtdParser.ParseFreeFloatingDtdAsync(_parserContext.BaseURI, _parserContext.DocTypeName, _parserContext.PublicId, _parserContext.SystemId, _parserContext.InternalSubset, proxy).ConfigureAwait(false);
            _coreReaderImpl.SetDtdInfo(dtdInfo);

            ValidateDtd();
        }
 private void ParseDocumentType(XmlDocumentType dtNode, bool bUseResolver, XmlResolver resolver)
 {
     this.doc = dtNode.OwnerDocument;
     XmlParserContext context = new XmlParserContext(null, new XmlNamespaceManager(this.doc.NameTable), null, null, null, null, this.doc.BaseURI, string.Empty, XmlSpace.None);
     XmlTextReaderImpl reader = new XmlTextReaderImpl("", XmlNodeType.Element, context) {
         Namespaces = dtNode.ParseWithNamespaces
     };
     if (bUseResolver)
     {
         reader.XmlResolver = resolver;
     }
     IDtdParser parser = DtdParser.Create();
     XmlTextReaderImpl.DtdParserProxy adapter = new XmlTextReaderImpl.DtdParserProxy(reader);
     IDtdInfo dtdInfo = parser.ParseFreeFloatingDtd(this.doc.BaseURI, dtNode.Name, dtNode.PublicId, dtNode.SystemId, dtNode.InternalSubset, adapter);
     this.LoadDocumentType(dtdInfo, dtNode);
 }