Ejemplo n.º 1
0
        protected XmlParserBase(XmlReaderParameters parameters)
        {
            m_mode = parameters.Mode;
            m_inferTypesFromSchema = parameters.ValidationOptions.HasFlag(XmlReaderValidationFlags.InferTypesFromSchema);

            if (parameters.ValidationOptions.HasFlag(XmlReaderValidationFlags.ValidateXsd))
            {
#if DISABLE_XMLVALIDATION
                throw new NotSupportedException("XML validation is not supported on this platform.");
#else
                XmlReaderSettings settings = new XmlReaderSettings();

                if (parameters.XsdStream != null)
                {
                    XmlSchemaSet sc = new XmlSchemaSet();
                    sc.Add("", System.Xml.XmlReader.Create(parameters.XsdStream));
                    settings.Schemas = sc;
                }
                settings.ValidationType   = ValidationType.Schema;
                settings.DtdProcessing    = DtdProcessing.Ignore;
                settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
                settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;

                if (parameters.ValidationOptions.HasFlag(XmlReaderValidationFlags.ReportValidationWarnings))
                {
                    settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
                }

                settings.ValidationEventHandler += (sender, e) =>
                {
                    throw new VariantException($"Validation {e.Severity}: {e.Message}");
                };
                m_reader = System.Xml.XmlReader.Create(parameters.XmlStream, settings, parameters.BaseUri);
#endif
            }
            else
            {
                m_reader = System.Xml.XmlReader.Create(parameters.XmlStream);
            }
        }
Ejemplo n.º 2
0
        protected XmlParserBase(XmlReaderParameters parameters)
        {
            m_mode = parameters.Mode;
            m_inferTypesFromSchema = parameters.ValidationOptions.HasFlag(XmlReaderValidationFlags.InferTypesFromSchema);

            if (parameters.ValidationOptions.HasFlag(XmlReaderValidationFlags.ValidateXsd))
            {
            #if DISABLE_XMLVALIDATION
                throw new NotSupportedException("XML validation is not supported on this platform.");
            #else
                XmlReaderSettings settings = new XmlReaderSettings();

                if (parameters.XsdStream != null)
                {
                    XmlSchemaSet sc = new XmlSchemaSet();
                    sc.Add("", System.Xml.XmlReader.Create(parameters.XsdStream));
                    settings.Schemas = sc;
                }
                settings.ValidationType = ValidationType.Schema;
                settings.DtdProcessing = DtdProcessing.Ignore;
                settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
                settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;

                if (parameters.ValidationOptions.HasFlag(XmlReaderValidationFlags.ReportValidationWarnings))
                {
                    settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
                }

                settings.ValidationEventHandler += (sender, e) =>
                                                   {
                                                       throw new VariantException($"Validation {e.Severity}: {e.Message}");
                                                   };
                m_reader = System.Xml.XmlReader.Create(parameters.XmlStream, settings, parameters.BaseUri);
            #endif
            }
            else
            {
                m_reader = System.Xml.XmlReader.Create(parameters.XmlStream);
            }
        }
Ejemplo n.º 3
0
 public XmlDefaultParser(XmlReaderParameters parameters)
     : base(parameters)
 {
     m_stack = new Stack<ElementInfo>();
     m_result = new Variant();
 }
Ejemplo n.º 4
0
 public XmlDefaultParser(XmlReaderParameters parameters) :
     base(parameters)
 {
     m_stack  = new Stack <ElementInfo>();
     m_result = new Variant();
 }