@Override
    public void writeByteRange(boolean utf8String, int fieldNumber, byte[] value,
            int offset, int length, boolean repeated) throws IOException
    {
        if (!utf8String)
        {
            // B64 encode
            writeB64(schema.getFieldName(fieldNumber), value, offset, length, repeated);
            return;
        }

        // write direct
        final String name = schema.getFieldName(fieldNumber);
        tail = sink.writeByte(END_TAG, this,
                sink.writeStrAscii(name, this,
                        sink.writeByteArray(START_SLASH_TAG, this,
                                sink.writeByteArray(value, offset, length, this,
                                        sink.writeByte(END_TAG, this,
                                                sink.writeStrAscii(name, this,
                                                        sink.writeByte(START_TAG, this, tail)))))));
    }
Before serializing a message/object tied to a schema, this should be called.
protostuff-xml/src/main/java/io/protostuff/XmlXOutput.java