System.Xml.Xsl.Xslt.XsltLoader.XslText C# (CSharp) Method

XslText() private method

private XslText ( ) : XslNode
return XslNode
        private XslNode XslText()
        {
            ContextInfo ctxInfo = _input.GetAttributes(_textAttributes);

            bool doe = ParseYesNoAttribute(0, /*attName:*/ "disable-output-escaping") == TriState.True;
            SerializationHints hints = doe ? SerializationHints.DisableOutputEscaping : SerializationHints.None;

            // We are not using StringBuilder here because in most cases there will be just one text node.
            List<XslNode> content = new List<XslNode>();

            QName parentName = _input.ElementName;
            if (_input.MoveToFirstChild())
            {
                do
                {
                    switch (_input.NodeType)
                    {
                        case XmlNodeType.Text:
                        case XmlNodeType.Whitespace:
                        case XmlNodeType.SignificantWhitespace:
                            // xsl:text may contain multiple child text nodes separated by comments and PIs, which are ignored by XsltInput
                            content.Add(f.Text(_input.Value, hints));
                            break;
                        default:
                            Debug.Assert(_input.NodeType == XmlNodeType.Element);
                            ReportError(/*[XT_023]*/SR.Xslt_UnexpectedElement, _input.QualifiedName, parentName);
                            _input.SkipNode();
                            break;
                    }
                } while (_input.MoveToNextSibling());
            }

            // Empty xsl:text elements will be ignored
            return SetInfo(f.List(), content, ctxInfo);
        }