SampleResource[] input = new SampleResource[] { r1, r2 };
// to see what JAXB might do, uncomment:
//System.out.println("By JAXB: "+jaxbSerialized(input));
String xml = xmlMapper
.writerWithDefaultPrettyPrinter()
.writeValueAsString(input)
.trim();
// first trivial sanity checks