Inheritance: XmlReader, IXmlSchemaInfo, IXmlLineInfo, IXmlNamespaceResolver
Example #1
0
        // We decided not to support XDR schema; it is obsolete.
        public override bool Read()
        {
            if (validatingReader == null)
            {
                switch (ValidationType)
                {
                case ValidationType.Auto:
                case ValidationType.None:
                    goto case ValidationType.Schema;                     // might be specified by xsi:schemaLocation.

                case ValidationType.DTD:
                    validatingReader      = dtdReader = new DTDValidatingReader(sourceReader, this);
                    dtdReader.XmlResolver = Resolver;
                    break;

                case ValidationType.Schema:
                    dtdReader = new DTDValidatingReader(sourceReader, this);
                    XsdValidatingReader xsvr = new XsdValidatingReader(dtdReader);
                    xsvr.ValidationEventHandler +=
                        new ValidationEventHandler(
                            OnValidationEvent);
                    xsvr.ValidationType   = ValidationType;
                    xsvr.Schemas          = Schemas.SchemaSet;
                    xsvr.XmlResolver      = Resolver;
                    validatingReader      = xsvr;
                    dtdReader.XmlResolver = Resolver;
                    break;

                case ValidationType.XDR:
                    throw new NotSupportedException();
                }
                schemaInfo = validatingReader as IHasXmlSchemaInfo;
            }
            return(validatingReader.Read());
        }
 internal XmlReader AddValidation(XmlReader reader)
 {
     if (this.validationType == ValidationType.Schema)
     {
         reader = new XsdValidatingReader(reader, GetXmlResolver_CheckConfig(), this);
     }
     else if (this.validationType == ValidationType.DTD)
     {
         reader = CreateDtdValidatingReader(reader);
     }
     return(reader);
 }
Example #3
0
 private XmlReader AddValidationAndConformanceWrapper(XmlReader reader)
 {
     if (this.validationType == System.Xml.ValidationType.DTD)
     {
         reader = this.CreateDtdValidatingReader(reader);
     }
     reader = this.AddConformanceWrapper(reader);
     if (this.validationType == System.Xml.ValidationType.Schema)
     {
         reader = new XsdValidatingReader(reader, this.GetXmlResolver(), this);
     }
     return(reader);
 }
Example #4
0
 internal XmlReader AddValidation(XmlReader reader)
 {
     if (this.validationType == System.Xml.ValidationType.Schema)
     {
         reader = new XsdValidatingReader(reader, this.GetXmlResolver(), this);
         return(reader);
     }
     if (this.validationType == System.Xml.ValidationType.DTD)
     {
         reader = this.CreateDtdValidatingReader(reader);
     }
     return(reader);
 }
Example #5
0
        private XmlReader AddValidationAndConformanceWrapper(XmlReader reader)
        {
            // wrap with DTD validating reader
            if (_validationType == ValidationType.DTD)
            {
                reader = CreateDtdValidatingReader(reader);
            }
            // add conformance checking (must go after DTD validation because XmlValidatingReader works only on XmlTextReader),
            // but before XSD validation because of typed value access
            reader = AddConformanceWrapper(reader);

            if (_validationType == ValidationType.Schema)
            {
                reader = new XsdValidatingReader(reader, GetXmlResolver_CheckConfig(), this);
            }
            return(reader);
        }
Example #6
0
        internal XmlReader AddValidation(XmlReader reader)
        {
            if (_validationType == ValidationType.Schema)
            {
                XmlResolver resolver = GetXmlResolver_CheckConfig();

                if (resolver == null &&
                    !this.IsXmlResolverSet)
                {
                    resolver = new XmlUrlResolver();
                }
                reader = new XsdValidatingReader(reader, resolver, this);
            }
            else if (_validationType == ValidationType.DTD)
            {
                reader = CreateDtdValidatingReader(reader);
            }
            return(reader);
        }
Example #7
0
        public override bool Read()
        {
            if (this.validatingReader == null)
            {
                switch (this.ValidationType)
                {
                case ValidationType.None:
                case ValidationType.Auto:
                    break;

                case ValidationType.DTD:
                    this.validatingReader      = (this.dtdReader = new DTDValidatingReader(this.sourceReader, this));
                    this.dtdReader.XmlResolver = this.Resolver;
                    goto IL_F3;

                case ValidationType.XDR:
                    throw new NotSupportedException();

                case ValidationType.Schema:
                    break;

                default:
                    goto IL_F3;
                }
                this.dtdReader = new DTDValidatingReader(this.sourceReader, this);
                XsdValidatingReader xsdValidatingReader  = new XsdValidatingReader(this.dtdReader);
                XsdValidatingReader xsdValidatingReader2 = xsdValidatingReader;
                xsdValidatingReader2.ValidationEventHandler = (ValidationEventHandler)Delegate.Combine(xsdValidatingReader2.ValidationEventHandler, new ValidationEventHandler(this.OnValidationEvent));
                xsdValidatingReader.ValidationType          = this.ValidationType;
                xsdValidatingReader.Schemas     = this.Schemas.SchemaSet;
                xsdValidatingReader.XmlResolver = this.Resolver;
                this.validatingReader           = xsdValidatingReader;
                this.dtdReader.XmlResolver      = this.Resolver;
IL_F3:
                this.schemaInfo = (this.validatingReader as IHasXmlSchemaInfo);
            }
            return(this.validatingReader.Read());
        }
Example #8
0
        private XmlReader AddValidationAndConformanceWrapper(XmlReader reader)
        {
            // wrap with DTD validating reader
            if (_validationType == ValidationType.DTD)
            {
                reader = CreateDtdValidatingReader(reader);
            }
            // add conformance checking (must go after DTD validation because XmlValidatingReader works only on XmlTextReader),
            // but before XSD validation because of typed value access
            reader = AddConformanceWrapper(reader);

            if (_validationType == ValidationType.Schema)
            {
                reader = new XsdValidatingReader(reader, GetXmlResolver_CheckConfig(), this);
            }
            return reader;
        }
Example #9
0
        internal XmlReader AddValidation(XmlReader reader)
        {
            if (_validationType == ValidationType.Schema)
            {
                XmlResolver resolver = GetXmlResolver_CheckConfig();

                if (resolver == null &&
                    !this.IsXmlResolverSet &&
                    !EnableLegacyXmlSettings())
                {
                    resolver = new XmlUrlResolver();
                }
                reader = new XsdValidatingReader(reader, resolver, this);
            }
            else if (_validationType == ValidationType.DTD)
            {
                reader = CreateDtdValidatingReader(reader);
            }
            return reader;
        }
        private static XmlReader CreateReaderImpl(XmlReader baseReader, XmlReaderSettings settings) {
            Debug.Assert(baseReader != null);
            Debug.Assert(settings != null);

            XmlReader reader = baseReader;

            // wrap with DTD validating reader
            if (settings.ValidationType == ValidationType.DTD) {
                reader = CreateDtdValidatingReader(reader, settings);
            }
            // add conformance checking (must go after DTD validation because XmlValidatingReader works only on XmlTextReader),
            // but before XSD validation because of typed value access
            reader = AddWrapper(reader, settings, reader.Settings);

            if (settings.ValidationType == ValidationType.Schema) {
                reader = new XsdValidatingReader(reader, settings.GetXmlResolver(), settings);
            }
            return reader;
        }
        private static XmlReader CreateReaderImpl(TextReader input, XmlReaderSettings settings, string baseUriStr,
                                                   XmlParserContext context) {
            if (input == null) {
                throw new ArgumentNullException("input");
            }
            if (settings == null) {
                settings = new XmlReaderSettings();
            }
            if (baseUriStr == null) {
                baseUriStr = string.Empty;
            }

            // create xml text reader
            XmlReader reader = new XmlTextReaderImpl(input, settings, baseUriStr, context);

            // wrap with validating reader
            if (settings.ValidationType == ValidationType.Schema) {
                reader = new XsdValidatingReader(reader, settings.GetXmlResolver(), settings);
            }
            else if (settings.ValidationType == ValidationType.DTD) {
                reader = CreateDtdValidatingReader(reader, settings);
            }
            return reader;
        }
 private static XmlReader AddValidation( XmlReader reader, XmlReaderSettings settings ) {
     if (settings.ValidationType == ValidationType.Schema) {
         reader = new XsdValidatingReader(reader, settings.GetXmlResolver(), settings);
     }
     else if (settings.ValidationType == ValidationType.DTD) {
         reader = CreateDtdValidatingReader(reader, settings);
     }
     return reader;
 }
 internal XmlReader AddValidation(XmlReader reader) {
     if (this.validationType == ValidationType.Schema) {
         reader = new XsdValidatingReader(reader, GetXmlResolver_CheckConfig(), this);
     }
     else if (this.validationType == ValidationType.DTD) {
         reader = CreateDtdValidatingReader(reader);
     }
     return reader;
 }
 private XmlReader AddValidationAndConformanceWrapper(XmlReader reader)
 {
     if (this.validationType == System.Xml.ValidationType.DTD)
     {
         reader = this.CreateDtdValidatingReader(reader);
     }
     reader = this.AddConformanceWrapper(reader);
     if (this.validationType == System.Xml.ValidationType.Schema)
     {
         reader = new XsdValidatingReader(reader, this.GetXmlResolver(), this);
     }
     return reader;
 }
 internal XmlReader AddValidation(XmlReader reader)
 {
     if (this.validationType == System.Xml.ValidationType.Schema)
     {
         reader = new XsdValidatingReader(reader, this.GetXmlResolver(), this);
         return reader;
     }
     if (this.validationType == System.Xml.ValidationType.DTD)
     {
         reader = this.CreateDtdValidatingReader(reader);
     }
     return reader;
 }