/// <summary>
        /// Throws an invalid name exception.
        /// </summary>
        /// <param name="s">String that was parsed.</param>
        /// <param name="offsetStartChar">Offset in string where parsing began.</param>
        /// <param name="offsetBadChar">Offset in string where parsing failed.</param>
        internal static void ThrowInvalidName(string s, int offsetStartChar, int offsetBadChar)
        {
            // If the name is empty, throw an exception
            if (offsetStartChar >= s.Length)
#if !SILVERLIGHT_XPATH
            { throw new XmlException("Xml_EmptyName"); }
#else
            { throw new XmlException(Res.GetString(Res.Xml_EmptyName, string.Empty)); }
#endif

            Debug.Assert(offsetBadChar < s.Length);

            if (xmlCharType.IsNCNameSingleChar(s[offsetBadChar]) && !XmlCharType.Instance.IsStartNCNameSingleChar(s[offsetBadChar]))
            {
                // The error character is a valid name character, but is not a valid start name character
#if !SILVERLIGHT_XPATH
                //throw new XmlException(Res.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(s, offsetBadChar));
                throw new XmlException("Xml_BadStartNameChar");
#else
                throw new XmlException(Res.GetString(Res.Xml_BadStartNameChar, XmlExceptionHelper.BuildCharExceptionArgs(s, offsetBadChar)));
#endif
            }
            else
            {
                // The error character is an invalid name character
#if !SILVERLIGHT_XPATH
                //throw new XmlException(Res.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(s, offsetBadChar));
                throw new XmlException("Xml_BadNameChar");
#else
                throw new XmlException(Res.GetString(Res.Xml_BadNameChar, XmlExceptionHelper.BuildCharExceptionArgs(s, offsetBadChar)));
#endif
            }
        }
Esempio n. 2
0
        private string ScanName()
        {
            ReadOnlySpan <char> span = _xpathExpr.AsSpan(_xpathExprIndex - 1);

            Debug.Assert(!span.IsEmpty);
            Debug.Assert(span[0] == CurrentChar);
            Debug.Assert(XmlCharType.IsStartNCNameSingleChar(span[0]));
            Debug.Assert(XmlCharType.IsNCNameSingleChar(span[0]));

            int i;

            for (i = 1; i < span.Length && XmlCharType.IsNCNameSingleChar(span[i]); i++)
            {
                ;
            }

            if ((uint)i < (uint)span.Length)
            {
                _currentChar     = span[i];
                _xpathExprIndex += i;
                return(span.Slice(0, i).ToString());
            }

            _currentChar     = '\0';
            _xpathExprIndex += i - 1;
            return(span.ToString());
        }
Esempio n. 3
0
        private string ScanName()
        {
            Debug.Assert(_xmlCharType.IsStartNCNameSingleChar(this.CurrentChar)
#if XML10_FIFTH_EDITION
                         || xmlCharType.IsNCNameHighSurrogateChar(this.CurerntChar)
#endif
                         );
            int start = _xpathExprIndex - 1;
            int len   = 0;

            for (;;)
            {
                if (_xmlCharType.IsNCNameSingleChar(this.CurrentChar))
                {
                    NextChar();
                    len++;
                }
#if XML10_FIFTH_EDITION
                else if (xmlCharType.IsNCNameSurrogateChar(this.PeekNextChar(), this.CurerntChar))
                {
                    NextChar();
                    NextChar();
                    len += 2;
                }
#endif
                else
                {
                    break;
                }
            }
            return(_xpathExpr.Substring(start, len));
        }
Esempio n. 4
0
        private string ScanNCName()
        {
            Debug.Assert(xmlCharType.IsStartNCNameSingleChar(curChar)
#if XML10_FIFTH_EDITION
                         || xmlCharType.IsNCNameHighSurrogateChar(curChar)
#endif
                         );
            int start = curIndex;
            for (;;)
            {
                if (xmlCharType.IsNCNameSingleChar(curChar))
                {
                    NextChar();
                }
#if XML10_FIFTH_EDITION
                else if (xmlCharType.IsNCNameSurrogateChar(PeekNextChar(), curChar))
                {
                    NextChar();
                    NextChar();
                }
#endif
                else
                {
                    break;
                }
            }
            return(xpathExpr.Substring(start, curIndex - start));
        }
Esempio n. 5
0
        /// <summary>
        /// Throws an invalid name exception.
        /// </summary>
        /// <param name="s">String that was parsed.</param>
        /// <param name="offsetStartChar">Offset in string where parsing began.</param>
        /// <param name="offsetBadChar">Offset in string where parsing failed.</param>
        internal static void ThrowInvalidName(string s, int offsetStartChar, int offsetBadChar)
        {
            // If the name is empty, throw an exception
            if (offsetStartChar >= s.Length)
            {
                throw new XmlException(ResXml.Xml_EmptyName, string.Empty);
            }

            Debug.Assert(offsetBadChar < s.Length);

            if (s_xmlCharType.IsNCNameSingleChar(s[offsetBadChar]) && !XmlCharType.Instance.IsStartNCNameSingleChar(s[offsetBadChar]))
            {
                // The error character is a valid name character, but is not a valid start name character
                throw new XmlException(ResXml.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(s, offsetBadChar));
            }
            else
            {
                // The error character is an invalid name character
                throw new XmlException(ResXml.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(s, offsetBadChar));
            }
        }
Esempio n. 6
0
        private string ScanNCName()
        {
            Debug.Assert(XmlCharType.IsStartNCNameSingleChar(_curChar));
            int start = _curIndex;

            while (true)
            {
                if (XmlCharType.IsNCNameSingleChar(_curChar))
                {
                    NextChar();
                }
                else
                {
                    break;
                }
            }
            return(_xpathExpr.Substring(start, _curIndex - start));
        }
Esempio n. 7
0
        private string ScanName()
        {
            Debug.Assert(_xmlCharType.IsStartNCNameSingleChar(this.CurrentChar));
            int start = _xpathExprIndex - 1;
            int len   = 0;

            while (true)
            {
                if (_xmlCharType.IsNCNameSingleChar(this.CurrentChar))
                {
                    NextChar();
                    len++;
                }
                else
                {
                    break;
                }
            }
            return(_xpathExpr.Substring(start, len));
        }