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;
}