Skip to content

How to use the XML Tokenize language as a predicate in a Content based Router?

Can we use body().xtokenize as predicate of choice() in Camel pipeline for routing when XML type matches the path we want?

I tried it but doesn’t filter in accordance with the predicate :

This is the code snippet :

 Namespaces ns = new Namespaces("ns1", "");
.choice().when(body().xtokenize("/ns1:Links", 'i', ns)) 

These are the type of XML content that I would like to route according to the name of the root element:

<Links xmlns="">
    <href>https://[source domain name]/public/api/aemp/v2/15143/-3/Fleet/Equipment/ID/[equipment


<Location datetime="2022-04-05T09:52:53Z">

Thank you for your help.



The XML Tokenize language is not really meant to be used as a predicate, you should rather use another language like the XPath language for example.

Your Content Based Router could test the local name of the root element to route your messages as next:

        .log("Link detected ${body}")
        .log("Location detected ${body}")
        .log("Unknown ${body}");