Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create xslt-transformer with JAVA config in Spring integration?

I have the following xslt-transformer in Spring-Integration. How can I do the same configuration with Java Config?

<si-xml:xslt-transformer input-channel="input" output-channel="output"
                         xsl-resource="classpath:/test.xsl"
                         result-transformer="resultToDoc"/>
like image 634
user1552545 Avatar asked Feb 26 '26 00:02

user1552545


2 Answers

@Transformer(inputChannel = "input", outputChannel = "output")
@Bean
public XsltPayloadTransformer transformer() {
    return new XsltPayloadTransformer(new ClassPathResource("classpath:/test.xsl"),
            resultToDoc());
}

From other side consider to use Spring Integration Java DSL, where the same will me much simpler:

@Value("classpath:/test.xsl")
private Resource xsl;

.transform(Transformers.xslt(this.xsl))
like image 199
Artem Bilan Avatar answered Feb 27 '26 12:02

Artem Bilan


@ServiceActivator(inputChannel="input")
@Bean
public MessageHandler xsltt() {
    MessageTransformingHandler handler = new MessageTransformingHandler(transformer());
    handler.setOutputChannelName("output");
    return handler;
}

@Bean
public Transformer transformer() {
    return new XsltPayloadTransformer(new ClassPathResource("classpath:/test.xsl"),
            resultToDoc());
}
like image 23
Gary Russell Avatar answered Feb 27 '26 14:02

Gary Russell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!