Profile profile = (Profile) j.next(); // Get the profile
if (transformer == null) { // No transformer/doc yet?
transformer = createTransformer(); // Then make the transformer
doc = Profile.createProfileDocument(); // And the doc
} // And use the doc ...
Node profileNode = profile.toXML(doc); // To render the profile into XML
DOMSource source = new DOMSource(profileNode); // And the XML becomes is source
StreamResult result = new StreamResult(res.getWriter()); // And the response is a result
transformer.transform(source, result); // And serialize into glorious text
sentAtLeastOne = true; // OK, we got at least one out the doo
}