我正在嘗試使用駝峰綁定將管道分隔的字符串?dāng)?shù)據(jù)轉(zhuǎn)換為 xml。但它正在生成標(biāo)簽和類名。我還想將命名空間添加到我的標(biāo)簽中。我嘗試使用 Camel 流程生成自定義標(biāo)簽,但它不起作用。ConverterRoute.java private static final String SOURCE_INPUT_PATH = "file://inbox?fileName=3000.txt"; private static final String SOURCE_OUTPUT_PATH = "file://outbox?fileName=itemfile.xml"; public void addRoutesToCamelContext(CamelContext context) throws Exception { context.addRoutes(new RouteBuilder() { public void configure() { try { DataFormat bindyFixed = new BindyCsvDataFormat(PartInboundIFD.class); NameSpace nameSpace = new NameSpace("PART_INB_IFD","https://apache.org.com"); from(SOURCE_INPUT_PATH). unmarshal(bindyFixed). marshal(). xstream(). to(SOURCE_OUTPUT_PATH); } catch (Exception e) { e.printStackTrace(); } } }); }}Pojo.java@CsvRecord(separator = "\\|",skipField = true)public class Pojo { @Link private ControlSegment CONTROL_SEGMENT;}CamelComponent.javapublic 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(); } }}輸出 結(jié)果.xml<list> <com.abc.domain.Pojo> <CONTROL__SEGMENT/> <TRNNAM>PART_TRAN</TRNNAM> <TRNVER>9.0</TRNVER> </com.abc.domain.Pojo></list>上面發(fā)布的是給定轉(zhuǎn)換的輸出。在第一個(gè)標(biāo)簽中,它打印帶有整個(gè)包和類名的標(biāo)簽名稱(例如:com.abc.domain.Pojo)。另外,我正在嘗試生成名稱空間,但它不會(huì)生成該名稱空間在我的輸出中。
如何使用 apache Camel 在 xml 中生成自定義標(biāo)簽名稱和命名空間
阿波羅的戰(zhàn)車
2023-09-13 18:10:26