Hi,
I am passing an Employee object on in channel for following configuration:
This produces following output:Code:<si:channel id="in"/> <si:channel id="out"/> <si:channel id="marshal"/> <si:channel id="toSplit"/> <si-xml:marshalling-transformer marshaller="castorMarshaller" input-channel="in" output-channel="marshal" result-type="DOMResult"/> <bean id="echo" class="si.EchoTransformer"/> <si:transformer input-channel="marshal" output-channel="toSplit" ref="echo" method="asDOMNode"/> <si-xml:xpath-splitter input-channel="toSplit" output-channel="out"> <si-xml:xpath-expression expression="/employee/interests/interest"/> </si-xml:xpath-splitter>
]Code:** Log: Inside Transformer [#document: null] ** [interest: null
But changing result-type to StringResult and transformer method to asString produces correct xml
Transformer methods are:Code:** Log: Inside Transformer <?xml version="1.0" encoding="UTF-8"?> <employee><location><city>London</city></location><name>Tim</name><interests><interest>architecture</interest></interests></employee> ** <?xml version="1.0" encoding="UTF-8"?><interest>architecture</interest>
DOMResult is preferred to avoid intermediate String<->DOM conversions.Code:public class EchoTransformer { public Node asDOMNode(DOMResult o) { Node node = o.getNode(); System.out.println("** Log: Inside Transformer"); System.out.println(node); System.out.println("**"); return node; } public String asString(Object o) { String str = o.toString(); System.out.println("** Log: Inside Transformer"); System.out.println(str); System.out.println("**"); return str; } }
Any help on why DOM node does not work here?
Thanks


Reply With Quote