throws Exception {
try {
StringWriter sWriter = new StringWriter();
PrintWriter sout = new PrintWriter(sWriter);
sout.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
TriplestoreReader reader = server.getReader();
String href = enc(requestURI.replaceAll("/$", ""));
sout.println("<query-service href=\"" + href + "\" context=\"" + enc(getContext(contextPath)) + "\">");
sout.println(" <alias-map>");
Map<String, String> map = reader.getAliasMap();
Iterator<String> iter = map.keySet().iterator();
while (iter.hasNext()) {
String name = iter.next();
String uri = map.get(name);
sout.println(" <alias name=\"" + name + "\" uri=\"" + enc(uri) + "\"/>");
}
sout.println(" </alias-map>");
sout.println(" <triple-languages>");
String[] langs = reader.listTripleLanguages();
for (int i = 0; i < langs.length; i++) {
sout.println(" <language name=\"" + enc(langs[i]) + "\"/>");
}
sout.println(" </triple-languages>");
langs = reader.listTupleLanguages();
sout.println(" <tuple-languages>");
for (int i = 0; i < langs.length; i++) {
sout.println(" <language name=\"" + enc(langs[i]) + "\"/>");
}
sout.println(" </tuple-languages>");