Skip to content

How to use both tokenize and simple in Spring DSL (XML route config) for Apache Camel in split?

I’d like to repoduce with XML the expression from Java DSL like this:


When I try to set up , consisting of two elements, and like that:

<split><tokenize token="#@#"><simple>${bodyAs(java.lang.String)} not contains ''</simple></tokenize></split>

Or like that:

<split><simple>${bodyAs(java.lang.String)} not contains ''</simple><tokenize token="#@#"></tokenize><split>

it doesn’t allow to validate the XML with the scheme:

org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 488; cvc-complex-type.2.2: Element 'tokenize' must have no element [children], and the value must be valid.


org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 475; cvc-complex-type.2.4.a: Invalid content was found starting with element 'tokenize'. One of '{"":aggregate, "":bean, "":doCatch, "":when, "":choice, "":otherwise, "":circuitBreaker, "":claimCheck, "":convertBodyTo, "":delay, "":dynamicRouter, "":enrich, "":filter, "":doFinally, "":idempotentConsumer, "":inOnly, "":inOut, "":intercept, "":interceptFrom, "":interceptSendToEndpoint, "":loadBalance, "":log, "":loop, "":marshal, "":multicast, "":onCompletion, "":onException, "":onFallback, "":pipeline, "":policy, "":pollEnrich, "":process, "":recipientList, "":removeHeader, "":removeHeaders, "":removeProperties, "":removeProperty, "":resequence, "":rollback, "":route, "":routingSlip, "":saga, "":sample, "":script, "":setBody, "":setExchangePattern, "":setHeader, "":setProperty, "":sort, "":split, "":step, "":stop, "":threads, "":throttle, "":throwException, "":to, "":toD, "":transacted, "":transform, "":doTry, "":unmarshal, "":validate, "":whenSkipSendToEndpoint, "":wireTap, "":serviceCall}' is expected.

So, it is impossible to put simple and tokenize together in XML, so how to do that?


Surprisingly, it worked for

<split><tokenize token="#@#">${bodyAs(java.lang.String)} contains '#@#'</tokenize></split>

i.e. <tokenize/> can have a body that is interpreted the same way as <simple/>