metadata.addContent(jdomDoc.detachRootElement());
root.addContent(metadata);
elem = Xml.transform(root, stylesheet);
} catch (Exception e) {
throw new FragmentTransformationException(e.getMessage());
}
// give back a DOM document with html as text (suits jzkit which expects
// html output to be text because parsing may not work)
Document output = null;
try {
output = htmldb.newDocument();
Element root = output.createElement("HTML");
root.appendChild( output.createTextNode(Xml.getString(elem)));
output.appendChild( root );
} catch ( Exception e ) {
throw new FragmentTransformationException(e.getMessage());
}
return output;
}