1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Collection collection = messages.values();
Iterator it = collection.iterator();
while (it.hasNext()){
NormalizedMessage nm = (NormalizedMessage)it.next();
Source source1 = (StreamSource)nm.getContent();
OutputStream o = new ByteArrayOutputStream();
StreamResult result = new StreamResult(o);
Transformer xformer;
try {
xformer = TransformerFactory.newInstance().newTransformer();
xformer.setOutputProperty(javax.xml.transform.OutputKeys.METHOD,"xml");
xformer.transform(source1, result);
} catch (TransformerConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerFactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
Partager