Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
3.11.1
-
None
-
Unknown
Description
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>
Attachments
Issue Links
- links to