I'm currently having a problem with the Transformer class that forced me to implement a "dirty" work-around. My objective is, starting with a SOAPMessage, being able to marshall a given node of the SOAPBody payload to an OutputStream.
I do that with the following code:
// "message" is a well-formated SOAPMessage.
final Transformer transformer=TransformerFactory.newInstance().newTransformer();
// "output" is the OutputStream.
transformer.transform(new DOMSource(node), new StreamResult(output));
It all works fine in the unit tests and standalone execution... The problem shows up when this code is integrated in our enterprise application, that runs on Tomcat. Instead of mashalling just the node tree, the transformer is marshalling THE WHOLE document! I proved that by caching the transformer output to a ByteArrayOutputStream and inspecting the results.
Deep cloning the node, which should remove all the parent elements, also doesn't work. I removed all the legacy XML APIs (xercesImpl.jar, xml-apis.jar, etc.) and the problem still persists.
I'm using Metro 1.3 on Java 1.5.0_10 in Windows XP. Tomcat version is 5.5.23.
Did any of you kind readers experienced this behaviour before? Thank you a lot in advance, cheers,