如何处理 xml 标签中的下划线。这是我正在工作的代码。它为我生成带有双下划线(“__”)而不是单下划线(“_”)的 xml 标记。谁能帮助我克服这个问题。
ConverterRoute.Java
public class ConverterRoute implements RoutesBuilder {
private static final String SOURCE_INPUT_PATH = "file://inbox?fileName=Source.txt";
private static final String SOURCE_OUTPUT_PATH = "file://outbox?fileName=file_$simple{date:now:yyyyMMddHHmmssSSS}.xml";
public void addRoutesToCamelContext(CamelContext context) throws Exception {
context.addRoutes(new RouteBuilder() {
public void configure() {
try {
DataFormat bindyFixed = new BindyCsvDataFormat(Test.class);
XStreamDataFormat xStreamDataFormat = new XStreamDataFormat();
xStreamDataFormat.setAliases(Collections.singletonMap("TEST_INB",Test.class.getCanonicalName()));
from(SOURCE_INPUT_PATH).
split().tokenize(System.lineSeparator()).
unmarshal(bindyFixed).
marshal(xStreamDataFormat).
to(SOURCE_OUTPUT_PATH).log("Finished Transformation").end();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
CamelConfig.java
@Component
public class CamelConfig extends RouteBuilder {
@Override
public void configure() throws Exception {
try {
CamelContext context = new DefaultCamelContext();
ConverterRoute route = new ConverterRoute();
route.addRoutesToCamelContext(context);
context.start();
Thread.sleep(5000);
context.stop();
} catch (Exception exe) {
exe.printStackTrace();
}
}
}
胡说叔叔
相关分类