Actually very simple. But, my input file is in form from a single line:
My Java code does not produce the desired output anymore, instead just this result:
After spending hours, I am pretty sure to already find out the reason:
It is because, after the transform method being executed, the cursor will automatically moved forward to the next event. And in the code, I have this fraction:
After the first transform, the streamReader gets directly 2 times next():
1. from the transform method
2. from the next method in the while loop
So, in case of this specific line XML, the cursor can never achive the second open tag <nextTag>.
In opposite, if the input XML has a pretty print form, the second <nextTag> can be reached from the cursor because there is a space-event after the first closing tag </nextTag>
Unfortunately, I could not find anything how to do settings, so that the transformator does not automatically spring to next event after performing the transform method. This is so frustating.
Does anybody have any idea how I can deal with it? Also semantically is very welcome. Thank you so much.
PS. I can surely write a workaround for this problem(pretty print the xml document before transforming it, but this would mean that the input xml was being modified before, this is not allowed).