fixed error for xml/html output: needed to call $format::setApi() before encoding of data