@Override
    public <T> void writeObject(int fieldNumber, T value, Schema<T> schema, boolean repeated)
            throws IOException
    {
        final Schema<?> lastSchema = this.schema;
        this.schema = schema;

        final String name = lastSchema.getFieldName(fieldNumber);

        // start tag
        tail = sink.writeByte(END_TAG, this,
                sink.writeStrAscii(name, this,
                        sink.writeByte(START_TAG, this, tail)));

        schema.writeTo(this, value);

        // end tag
        tail = sink.writeByte(END_TAG, this,
                sink.writeStrAscii(name, this,
                        sink.writeByteArray(START_SLASH_TAG, this, tail)));

        // restore state
        this.schema = lastSchema;
    }
Before serializing a message/object tied to a schema, this should be called.
protostuff-xml/src/main/java/io/protostuff/XmlXOutput.java