*/
private Sequence encodeResponseAsXML(final XQueryContext context, final HttpMethod method, final int statusCode, final Map<String, Boolean> parserFeatures, final Map<String, String> parserProperties) throws XPathException, IOException {
final MemTreeBuilder builder = context.getDocumentBuilder();
builder.startDocument();
builder.startElement(new QName("response", NAMESPACE_URI, PREFIX), null );
builder.addAttribute(new QName("statusCode", null, null), String.valueOf(statusCode));
//Add all the response headers
builder.startElement(new QName("headers", NAMESPACE_URI, PREFIX), null);