Пример #1
0
        // Read a name, calling Error if there are no valid characters.
        public virtual String ReadName()
        {
            // push a new log
            Logger.Push(new StringBuilder());

            // require an initial name character
            if (!NextChar())
            {
                Error("Xml_UnexpectedEOF");
            }
            if (!XmlCharInfo.IsNameInit(currChar))
            {
                Error(/* TODO */);
            }

            // read until we consume all the name characters
            while (PeekChar() && XmlCharInfo.IsNameChar(peekChar))
            {
                NextChar();
            }

            // get the result from the log and pop it from the logger
            String result = Logger.Pop().ToString();

            // return our result
            return(nameTable.Add(result));
        }
Пример #2
0
        // Move to the next character, returning false on EOF.
        public override bool NextChar()
        {
            bool retval;

            if (peValue == null)
            {
                retval   = input.NextChar();
                currChar = input.currChar;
                if (!scanForPE)
                {
                    return(retval);
                }
                if (currChar == '%')
                {
                    if (input.PeekChar() &&
                        XmlCharInfo.IsNameInit(input.peekChar))
                    {
                        String name = input.ReadName();
                        input.Expect(';');
                        peValue    = parameterEntities[name];
                        pePosition = 0;
                        currChar   = ' ';
                    }
                }
            }
            else
            {
                retval = true;
                if (pePosition == -1)
                {
                    pePosition++;
                    currChar = ' ';
                }
                else if (pePosition < peValue.Length)
                {
                    currChar = peValue[pePosition++];
                }
                else
                {
                    pePosition = -1;
                    peValue    = null;
                    currChar   = ' ';
                }
            }
            return(retval);
        }