@Override
    public <T> int readFieldNumber(final Schema<T> schema) throws IOException
    {
        if (emptyMessage)
        {
            emptyMessage = false;
            return 0;
        }

        if (parser.getEventType() == END_ELEMENT)
            return 0;

        final String name = parser.getLocalName();
        final int num = schema.getFieldNumber(name);

        if (num == 0)
        {
            while (true)
            {
                switch (next())
                {
                    case END_ELEMENT:
                        if (name.equals(parser.getLocalName()))
                        {
                            // we can skip this unknown scalar field.
                            nextTag();
                            return readFieldNumber(schema);
                        }
                        throw new XmlInputException("Unknown field: " + name + " on message " +
                                schema.messageFullName());
                    case END_DOCUMENT:
                        // malformed xml.
                    case START_ELEMENT:
                        // message field
                        // we do not know how deep this message is
                        throw new XmlInputException("Unknown field: " + name + " on message " +
                                schema.messageFullName());
                }
            }
        }

        return num;
    }
An input used for reading data with xml format.

@author David Yu
@created May 24, 2010
protostuff-xml/src/main/java/io/protostuff/XmlInput.java