Hi Buddy,

If you call Java code from XQuery, your nodes might be copied to a
Java-specific representation, and the node identity might change. If
you stick to the native data structures (did you try the XQuery map),
everything should be fine.

Hope this helps,

Christian


On Fri, Jun 5, 2020 at 6:05 AM Buddy Kresge <buddy.kre...@known2u.com> wrote:
>
> This can be reproduced in 9.2.4 and 9.3.3 (only tried those 2 versions)
>
>
>
> We are using java:HashMap, and we are seeing that when we insert a node into 
> the HashMap from a file and do a subsequent hash:get, the generate-id() for 
> the hash:get is different than the original generate-id value from the 
> hash:put.
>
> Note:  when we read the XML from a file, that is when we see the issue, if we 
> declare the XML in Basex GUI, we do NOT see this behavior.  Here are the 
> examples:
>
>
>
> Scenario #1:  XML is a variable in the BaseX GUI session --- no bug
>
> ----------------------------------------------------------------------------------------
>
> declare namespace hash = "java:java.util.HashMap";
>
> let $data := <A>
>
>    <B>
>
>        <C>
>
>            <Message>Hi there</Message>
>
>            <Message>How are you</Message>
>
>            <D>
>
>                <E>1</E>
>
>            </D>
>
>        </C>
>
>    </B>
>
> </A>
>
> let $node := $data//*:C
>
>
>
> let $kb := hash:new()
>
> let $nullOp := hash:put($kb, generate-id($node), $node)
>
> let $getNode := hash:get($kb,  generate-id($node))
>
> return
>
> (generate-id($node), generate-id($getNode))
>
>
>
> Result:
>
> id6312150
>
> id6312150
>
>
>
> Scenario #2:  XML is  read in from a file --- bug appears
>
> ----------------------------------------------------------------------------------------
>
> Move the data into a file and then read in from the file, that is when we see 
> the issue.
>
>
>
> declare namespace hash = "java:java.util.HashMap";
>
> let $file := doc('SampleData.xml')
>
> let $node := $file//*:C[1]
>
>
>
> let $kb := hash:new()
>
> let $null := hash:put($kb, generate-id($node), $node)
>
> let $getNode := hash:get($kb,  generate-id($node))
>
> return
>
> (generate-id($node), generate-id($getNode))
>
>
>
> Result:
>
> id30601d5
>
> id30602d0
>
>
>
>
>
> Thanks in advance for your assistance
>
>
>
> Buddy

Reply via email to