javaapache-camelstaxwoodstox

How to configure Woodstox properties in using Apache Camel?


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();

Solution

  • 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.

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