[ 
https://issues.apache.org/jira/browse/CAMEL-16865?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen resolved CAMEL-16865.
---------------------------------
      Assignee: Claus Ibsen
    Resolution: Fixed

Thanks for detailed reporting and providing a fix with an unit test.

> Xtokenize does not track a level up again once it detects a non matching 
> namespace
> ----------------------------------------------------------------------------------
>
>                 Key: CAMEL-16865
>                 URL: https://issues.apache.org/jira/browse/CAMEL-16865
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 3.11.1
>            Reporter: Ruben Gerits
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 3.7.6, 3.11.2, 3.12.0
>
>
> 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:
> {code: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>
>  {code}
> And we run the xtokenize expression as following (within test class 
> {{XMLTokenExpressionIteratorTest}}):
> {code:java}
> nsmap.put("X", "urn:x");
> invokeAndVerify("//G:grandparent/X:*",
>         'i', new ByteArrayInputStream(TEST_BODY_MIXED_CHILDREN), 
> RESULTS_AUNT_AND_UNCLE);
> {code}
> As a result we now get:
> {code:xml}
> <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>
> {code}
> 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:
> {code:xml}
> <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>
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to