private static String prettyPrint(XdmValue xdm) throws Exception {
Activator.logInfo("Pretty printing");
Writer result = new StringWriter();
XsltTransformer xsltTransformer = xsltExec.load();
xsltTransformer.setDestination(new Serializer(result));
for (XdmItem item: xdm) {
if (item instanceof XdmNode) {
xsltTransformer.setInitialContextNode((XdmNode) item);
xsltTransformer.transform();