예제 #1
0
        public void Reset()
        {
            checkCharacters = true;
            closeInput      = false;        // ? not documented
            conformance     = ConformanceLevel.Document;
            ignoreComments  = false;
            ignoreProcessingInstructions = false;
            ignoreWhitespace             = false;
            lineNumberOffset             = 0;
            linePositionOffset           = 0;
            prohibitDtd = true;
            schemas     = null;
            schemasNeedsInitialization = true;
            validationFlags            =
                XsValidationFlags.ProcessIdentityConstraints |
                XsValidationFlags.AllowXmlAttributes;
            validationType = ValidationType.None;
            xmlResolver    = new XmlUrlResolver();
#if NET_4_5
            isAsync = false;
#endif
        }
예제 #2
0
        // Extra for XmlSchemaValidtingReader
        // (not in XsdValidatingReader)
        //XsElement element; // ... xsinfo.Element?

        #endregion

        public XmlSchemaValidatingReader(XmlReader reader,
                                         XmlReaderSettings settings)
        {
            IXmlNamespaceResolver nsResolver = reader as IXmlNamespaceResolver;

            if (nsResolver == null)
            {
                //	throw new ArgumentException ("Argument XmlReader must implement IXmlNamespaceResolver.");
                nsResolver = new XmlNamespaceManager(reader.NameTable);
            }

            XmlSchemaSet schemas = settings.Schemas;

            if (schemas == null)
            {
                schemas = new XmlSchemaSet();
            }
            options = settings.ValidationFlags;

            this.reader = reader;
            v           = new XmlSchemaValidator(
                reader.NameTable,
                schemas,
                nsResolver,
                options);
            if (reader.BaseURI != String.Empty && Uri.IsWellFormedUriString(reader.BaseURI, UriKind.Absolute))
            {
                v.SourceUri = new Uri(reader.BaseURI);
            }

            readerLineInfo = reader as IXmlLineInfo;
            getter         = delegate() {
                if (v.CurrentAttributeType != null)
                {
                    return(v.CurrentAttributeType.ParseValue(Value, NameTable, this));
                }
                else
                {
                    return(Value);
                }
            };
            xsinfo                  = new XmlSchemaInfo(); // transition cache
            v.LineInfoProvider      = this;
            v.ValidationEventSender = reader;
            this.nsResolver         = nsResolver;
#if !NON_MONO
            ValidationEventHandler += delegate(object o, ValidationEventArgs e) {
                settings.OnValidationError(o, e);
            };
            if (settings != null && settings.Schemas != null)
            {
                v.XmlResolver = settings.Schemas.XmlResolver;
            }
            else
            {
                v.XmlResolver = new XmlUrlResolver();
            }
#else
            v.XmlResolver = new XmlUrlResolver();
#endif
            v.Initialize();
        }