System.Xml.Schema.Parser.ParseReaderNode C# (CSharp) Méthode

ParseReaderNode() public méthode

public ParseReaderNode ( ) : bool
Résultat bool
        public bool ParseReaderNode()
        {
            if (_reader.Depth > _markupDepth)
            {
                if (_processMarkup)
                {
                    ProcessAppInfoDocMarkup(false);
                }
                return true;
            }
            else if (_reader.NodeType == XmlNodeType.Element)
            {
                if (_builder.ProcessElement(_reader.Prefix, _reader.LocalName, _reader.NamespaceURI))
                {
                    _namespaceManager.PushScope();
                    if (_reader.MoveToFirstAttribute())
                    {
                        do
                        {
                            _builder.ProcessAttribute(_reader.Prefix, _reader.LocalName, _reader.NamespaceURI, _reader.Value);
                            if (Ref.Equal(_reader.NamespaceURI, _schemaNames.NsXmlNs) && _isProcessNamespaces)
                            {
                                _namespaceManager.AddNamespace(_reader.Prefix.Length == 0 ? string.Empty : _reader.LocalName, _reader.Value);
                            }
                        }
                        while (_reader.MoveToNextAttribute());
                        _reader.MoveToElement(); // get back to the element
                    }
                    _builder.StartChildren();
                    if (_reader.IsEmptyElement)
                    {
                        _namespaceManager.PopScope();
                        _builder.EndChildren();
                        if (_reader.Depth == _schemaXmlDepth)
                        {
                            return false; // done
                        }
                    }
                    else if (!_builder.IsContentParsed())
                    { //AppInfo and Documentation
                        _markupDepth = _reader.Depth;
                        _processMarkup = true;
                        if (_annotationNSManager == null)
                        {
                            _annotationNSManager = new XmlNamespaceManager(_nameTable);
                            _xmlns = _nameTable.Add("xmlns");
                        }
                        ProcessAppInfoDocMarkup(true);
                    }
                }
                else if (!_reader.IsEmptyElement)
                { //UnsupportedElement in that context
                    _markupDepth = _reader.Depth;
                    _processMarkup = false; //Hack to not process unsupported elements
                }
            }
            else if (_reader.NodeType == XmlNodeType.Text)
            { //Check for whitespace
                if (!_xmlCharType.IsOnlyWhitespace(_reader.Value))
                {
                    _builder.ProcessCData(_reader.Value);
                }
            }
            else if (_reader.NodeType == XmlNodeType.EntityReference ||
                _reader.NodeType == XmlNodeType.SignificantWhitespace ||
                _reader.NodeType == XmlNodeType.CDATA)
            {
                _builder.ProcessCData(_reader.Value);
            }
            else if (_reader.NodeType == XmlNodeType.EndElement)
            {
                if (_reader.Depth == _markupDepth)
                {
                    if (_processMarkup)
                    {
                        Debug.Assert(_parentNode != null);
                        XmlNodeList list = _parentNode.ChildNodes;
                        XmlNode[] markup = new XmlNode[list.Count];
                        for (int i = 0; i < list.Count; i++)
                        {
                            markup[i] = list[i];
                        }
                        _builder.ProcessMarkup(markup);
                        _namespaceManager.PopScope();
                        _builder.EndChildren();
                    }
                    _markupDepth = int.MaxValue;
                }
                else
                {
                    _namespaceManager.PopScope();
                    _builder.EndChildren();
                }
                if (_reader.Depth == _schemaXmlDepth)
                {
                    return false; // done
                }
            }
            return true;
        }

Usage Example

 private void ProcessInlineSchema()
 {
     if (!inlineSchemaParser.ParseReaderNode())   // Done
     {
         inlineSchemaParser.FinishParsing();
         XmlSchema schema   = inlineSchemaParser.XmlSchema;
         string    inlineNS = null;
         if (schema != null && schema.ErrorCount == 0)
         {
             try {
                 SchemaInfo inlineSchemaInfo = new SchemaInfo();
                 inlineSchemaInfo.SchemaType = SchemaType.XSD;
                 inlineNS = schema.TargetNamespace == null? string.Empty : schema.TargetNamespace;
                 if (!SchemaInfo.TargetNamespaces.ContainsKey(inlineNS))
                 {
                     if (SchemaCollection.Add(inlineNS, inlineSchemaInfo, schema, true) != null)   //If no errors on compile
                     //Add to validator's SchemaInfo
                     {
                         SchemaInfo.Add(inlineSchemaInfo, EventHandler);
                     }
                 }
             }
             catch (XmlSchemaException e) {
                 SendValidationEvent(Res.Sch_CannotLoadSchema, new string[] { BaseUri.AbsoluteUri, e.Message }, XmlSeverityType.Error);
             }
         }
         inlineSchemaParser = null;
     }
 }
All Usage Examples Of System.Xml.Schema.Parser::ParseReaderNode