public Appendable format(Object source, Appendable ap) throws IOException {
Context context = new Context();
OutputSource fs;
if (ap instanceof Writer) {
fs = new WriterOutputSource((Writer)ap);
} else if (ap instanceof StringBuilder) {
fs = new StringBuilderOutputSource((StringBuilder)ap);
} else {
fs = new AppendableOutputSource(ap);
}