private QilNode ExtractText(string source, ref int pos)
{
Debug.Assert(pos < source.Length);
int i, start = pos;
_unescapedText.Length = 0;
for (i = pos; i < source.Length; i++)
{
char ch = source[i];
if (ch == '{' || ch == '}')
{
if (i + 1 < source.Length && source[i + 1] == ch)
{ // "{{" or "}}"
// Double curly brace outside an expression is replaced by a single one
i++;
_unescapedText.Append(source, start, i - start);
start = i + 1;
}
else if (ch == '{')
{ // single '{'
// Expression encountered, returning
break;
}
else
{ // single '}'
// Single '}' outside an expression is an error
pos = source.Length;
if (_xslVersion != XslVersion.ForwardsCompatible)
{
ReportError(/*[XT0370]*/SR.Xslt_SingleRightBraceInAvt, source);
return null;
}
return _f.Error(_lastScope.SourceLine, SR.Xslt_SingleRightBraceInAvt, source);
}
}
}
Debug.Assert(i == source.Length || source[i] == '{');
pos = i;
if (_unescapedText.Length == 0)
{
return i > start ? _f.String(source.Substring(start, i - start)) : null;
}
else
{
_unescapedText.Append(source, start, i - start);
return _f.String(_unescapedText.ToString());
}
}