Feb 1st, 2011, 06:04 AM
Specifying a custom TransformerFactory
How do I override the default TransformerFactory?
I can see that TransformerObjectSupport has a transformerFactoryClass property but I can't see any way to access that bean.
The reason I want to override the default Transformer (com.sun.org.apache.xalan.internal.xsltc.trax.Tran sformerImpl) is because my SOAP response has an xs:string element that happens to contain an XML document. Because the XML doc can be very large I've taken care to enclose it in a CDATA section rather than use XML escaping. Problem is, it looks like the default transformer parses my nested XML to a logical TextNode, which eventually gets marshaled out as escaped XML (i.e. no CDATA)! I'm hoping that a custom transformer will enable me to take control so that my CDATA section remains.
Aside: I confess I don't really understand the role of the transformer in Spring-WS. My PayloadEndpoint.invoke() method returns a Source for my top-level element. Why can't this simply be enclosed in a SOAP envelope without the need for transformation? I must be missing something.
Thanks for any advice.