/// <summary> /// Visit an <see cref="XmlTextSyntax"/>. /// </summary> /// <param name="text"> /// The <see cref="XmlTextSyntax"/>. /// </param> /// <returns> /// The <see cref="XmlTextSyntax"/> (unchanged). /// </returns> public override SyntaxNode VisitXmlText(XmlTextSyntax text) { Range textRange = text.Span.ToNative(_textPositions); if (CurrentElement == null || !CurrentElement.Range.Contains(textRange)) { return(text); } XSElementText elementText = new XSElementText(text, textRange, CurrentElement); CurrentElement.Content = CurrentElement.Content.Add(elementText); DiscoveredNodes.Add(elementText); return(text); }
/// <summary> /// Does the location represent an element's textual content? /// </summary> /// <param name="location"> /// The XML location. /// </param> /// <param name="text"> /// Receives the <see cref="XSElementText"/>. /// </param> /// <returns> /// <c>true</c>, if the location represents an element's textual content; otherwise, <c>false</c>. /// </returns> public static bool IsElementText(this XmlLocation location, out XSElementText text) { if (location == null) { throw new ArgumentNullException(nameof(location)); } if (location.IsElementText()) { text = (XSElementText)location.Node; return(true); } else { text = null; return(false); } }