abstract private ProcessMarkup ( |
||
markup | ||
리턴 | void |
internal bool ParseReaderNode() { if (reader.Depth > markupDepth) { if (writer != null) // ProcessMarkup { switch (reader.NodeType) { case XmlNodeType.Element: writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI); writer.WriteAttributes(reader, false); if (reader.IsEmptyElement) { writer.WriteEndElement(); } break; case XmlNodeType.Text: writer.WriteString(reader.Value); break; case XmlNodeType.SignificantWhitespace: writer.WriteWhitespace(reader.Value); break; case XmlNodeType.CDATA: writer.WriteCData(reader.Value); break; case XmlNodeType.EntityReference: writer.WriteEntityRef(reader.Name); break; case XmlNodeType.Comment: writer.WriteComment(reader.Value); break; case XmlNodeType.EndElement: writer.WriteFullEndElement(); break; } } return(true); } 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 == string.Empty ? 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(); } else if (!builder.IsContentParsed()) { markupDepth = reader.Depth; stringWriter = new StringWriter(); writer = new XmlTextWriter(stringWriter); writer.WriteStartElement(reader.LocalName); } } else if (!reader.IsEmptyElement) { markupDepth = reader.Depth; writer = null; } } else if (reader.NodeType == XmlNodeType.Text || 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 (writer != null) // processUnparsedContent { writer.WriteEndElement(); writer.Close(); writer = null; XmlDocument doc = new XmlDocument(); doc.Load(new XmlTextReader(new StringReader(stringWriter.ToString()))); XmlNodeList list = doc.DocumentElement.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); }
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(); } 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 || 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); }
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); }