gerits opened a new pull request #5955:
URL: https://github.com/apache/camel/pull/5955
When trying to find all items of a specific namespace within a parent tag it
will stop detecting the children once it comes across a parent tag that does
not have any child elements within this namespace.
It seems that the code to go up a level again is only triggered once a
matching child element has been found. If no elements are found this logic is
not triggered, even though the xml tag ends at that level.
For example having XML:
```
<?xml version='1.0' encoding='UTF-8'?>
<greatgrandparent xmlns='urn:g' xmlns:c='urn:c' xmlns:x='urn:x'>
<grandparent>
<x:uncle>bob</x:uncle>
<x:aunt>emma</x:aunt>
</grandparent>
<grandparent>
<c:parent some_attr='1'>
<c:child some_attr='a' anotherAttr='a'></c:child>
<c:child some_attr='b' anotherAttr='b' />
</c:parent>
<c:parent some_attr='2'>
<c:child some_attr='c' anotherAttr='c'></c:child>
<c:child some_attr='d' anotherAttr='d' />
</c:parent>
</grandparent>
<grandparent>
<x:uncle>ben</x:uncle>
<x:aunt>jenna</x:aunt>
<c:parent some_attr='3'>
<c:child some_attr='e' anotherAttr='e'></c:child>
<c:child some_attr='f' anotherAttr='f' />
</c:parent>
</grandparent>
</greatgrandparent>
```
And we run the xtokenize expression as following (within test class
`XMLTokenExpressionIteratorTest`):
```
nsmap.put("X", "urn:x");
invokeAndVerify("//G:grandparent/X:*",
'i', new ByteArrayInputStream(TEST_BODY_MIXED_CHILDREN),
RESULTS_AUNT_AND_UNCLE);
```
As a result we now get:
```
<x:uncle xmlns=\"urn:g\" xmlns:x=\"urn:x\" xmlns:c=\"urn:c\">bob</x:uncle>
<x:aunt xmlns=\"urn:g\" xmlns:x=\"urn:x\" xmlns:c=\"urn:c\">emma</x:aunt>
```
This means it stops processing at the moment it got to the grandparent tag
that only has `<c:child>` elements.
The expected result would be:
```
<x:uncle xmlns=\"urn:g\" xmlns:x=\"urn:x\" xmlns:c=\"urn:c\">bob</x:uncle>
<x:aunt xmlns=\"urn:g\" xmlns:x=\"urn:x\" xmlns:c=\"urn:c\">emma</x:aunt>
<x:uncle xmlns=\"urn:g\" xmlns:x=\"urn:x\" xmlns:c=\"urn:c\">ben</x:uncle>
<x:aunt xmlns=\"urn:g\" xmlns:x=\"urn:x\" xmlns:c=\"urn:c\">jenna</x:aunt>
```
- [x] Make sure there is a [JIRA
issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change
(usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue,
without pulling in other changes.
- [x] Each commit in the pull request should have a meaningful subject line
and body.
- [x] If you're unsure, you can format the pull request title like
`[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX`
with the appropriate JIRA issue.
- [x] Write a pull request description that is detailed enough to understand
what the pull request does, how, and why.
- [x] Run `mvn clean install -Psourcecheck` in your module with source check
enabled to make sure basic checks pass and there are no checkstyle violations.
A more thorough check will be performed on your pull request automatically.
Below are the contribution guidelines:
https://github.com/apache/camel/blob/main/CONTRIBUTING.md
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]