如何在使用Apache Camel中配置Woodstox属性?

huangapple go评论85阅读模式
英文:

How to configure Woodstox properties in using Apache Camel?

问题

根据woodstox的GitHub页面 https://github.com/FasterXML/woodstox/issues/59

可以通过XMLInputFactory配置Woodstox属性。

我现在正在使用带有JAVA DSL的Camel,它使用woodstox-core处理XML
https://camel.apache.org/components/next/eips/split-eip.html#_streaming_big_xml_payloads_using_xml_tokenize_language

我想配置Woodstox属性,例如 WstxInputProperties.P_RETURN_NULL_FOR_DEFAULT_NAMESPACE

如何在Apache Camel中配置Woodstox属性?

(Java 8,Apache Camel 2.25.4)

参考代码:

camel:

        Exchange in = camelContext.getEndpoint("direct:xxx").createExchange();
        in.getIn().setBody(xmlContent);
        ProducerTemplate template = camelContext.createProducerTemplate();
        Exchange out = template.send("direct:xxx", in);
---
route builder:

        from("direct:xxx")
                .routeId("xxx")
                .split(body().xtokenize("//xxx:xxx", 'i', ns), myAggregationStrategy)
                    .process(myProcessor)
                .end();
英文:

According to woodstox github https://github.com/FasterXML/woodstox/issues/59

Woodstox properties can be configured through XMLInputFactory.

I'm now using camel with JAVA DSL, which use woodstox-core for XML
https://camel.apache.org/components/next/eips/split-eip.html#_streaming_big_xml_payloads_using_xml_tokenize_language

I want to configure Woodstox property e.g. WstxInputProperties.P_RETURN_NULL_FOR_DEFAULT_NAMESPACE

How can I configure Woodstox properties in using Apache Camel?

(Java 8, Apache Camel 2.25.4)

Code for reference:

camel:

        Exchange in = camelContext.getEndpoint("direct:xxx").createExchange();
        in.getIn().setBody(xmlContent);
        ProducerTemplate template = camelContext.createProducerTemplate();
        Exchange out = template.send("direct:xxx", in);
---
route builder:

        from("direct:xxx")
                .routeId("xxx")
                .split(body().xtokenize("//xxx:xxx", 'i', ns), myAggregationStrategy)
                    .process(myProcessor)
                .end();

答案1

得分: 0

我已将此错误报告给Apache。由于camel 2.25.4已经到了生命周期结束(EOL)阶段,它将在新版本的camel-stax中修复。

修复版本:
3.14.9, 3.18.8, 3.20.6, 3.21.0, 4.0-RC1, 4.0

如果无法升级camel版本,可以考虑在所有xml标签上添加自定义命名空间来避免此问题,而不是使用xml默认命名空间,例如:

<ns1:XX ... xmlns:ns1="XXXX">
    <ns1:YY>zzz</ns1:YY>
</ns1:XX>
英文:

I've reported this bug to Apache. As camel 2.25.4 is already EOL, it will be fixed at new version of camel-stax.

Fix Version/s:
3.14.9, 3.18.8, 3.20.6, 3.21.0, 4.0-RC1, 4.0

https://issues.apache.org/jira/browse/CAMEL-19415

If it is not possible to upgrade the camel version, instead of using xml default namespace, adding a custom namespace on all xml tag should be a possible way to avoid this issue. i.e.

&lt;ns1:XX ... xmlns:ns1=&quot;XXXX&quot;&gt;
    &lt;ns1:YY&gt;zzz&lt;/ns1:YY&gt;
&lt;/ns1:XX&gt;

huangapple
  • 本文由 发表于 2023年6月1日 17:35:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76380521.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定