|
Replies:
5
-
Last Post:
Apr 27, 2012 3:46 PM
Last Post By: davsclaus
|
Threads:
[
Previous
|
Next
]
|
|
Posts:
87
Registered:
02/24/09
|
|
|
|
The splitter - how does it work ?
Posted:
Apr 26, 2012 10:58 AM
|
|
|
|
Greetings,
Looking at the splitter, I was thinking that it is recursive. I mean, given a route like the following:
from("...").split(body().tokenize("...")).streaming().unmarshal(new JaxbDataFormat(...))
it would go through the whole file and it will cyclicly take each record (delimited by the token) and unmarshall it, etc.
But after having tested it, it seems that it only does it with the first record, ie until it finds the first occurrence of the token. Looking in the documentation at the "What the splitter returns", it says that it returns the last splitted message which, in my case, is the first record in the file. So this is what happened.
But I'm confused now as I need to cycle, occurrence of token by occurrence of token, until the end of the file.
How could I don this ?
Many thanks in advance,
Nicolas
|
|
|
|
Posts:
1,863
Registered:
10/14/08
|
|
|
|
Re: The splitter - how does it work ?
Posted:
Apr 26, 2012 11:27 AM
in response to: nicolasduminil
|
|
|
|
It will iterate the expression, so in your case you are tokenizing the message body. Camel uses the java.util.Scanner when you use the tokenize in the DSL. So make sure that this tokenizer works as expected.
|
|
|
|
|
Posts:
87
Registered:
02/24/09
|
|
|
|
Re: The splitter - how does it work ?
Posted:
Apr 26, 2012 1:49 PM
in response to: davsclaus
|
|
|
|
Hi Claus,
Thank you for helping again. Yes, the problem comes from the tokenizer. I made a separate test using the java.util.Scanner and it appears that it doesn't work as I expected. I have an XML file and I want to split it XML element by XML element.
For example:
<0>
<a>11111111111</a>
<b>22222222222</b>
............................
</0>
And i use "</0>" as a tokenizer but, what happens is that the tokenizer itself, ie "</0>", is not included. Is there any option to specify a splitting such that to have every thing between <0> and </0>, including <0> and </0>, i any splited part ?
Many thanks in advance,
Nicolas
|
|
|
|
|
Posts:
1,863
Registered:
10/14/08
|
|
|
|
|
Posts:
87
Registered:
02/24/09
|
|
|
|
Re: The splitter - how does it work ?
Posted:
Apr 27, 2012 3:44 PM
in response to: davsclaus
|
|
|
|
Hi Claus,
Many thanks. The current file is not too big and the splitting works for now, but it may become much larger. The problem is that the stax parsing and the XML tokens are supported, as far as I understood, starting with Camel 2.9 which is not yet available in download on the FuseSource web-site. It may be available at the Apache site but we are using the FuseSource one.
Kind regards,
Nicolas
|
|
|
|
|
Posts:
1,863
Registered:
10/14/08
|
|
|
|
|
|