I would expect the corresponding Java code which produces the same result of the XQuery code. Isn't this what happens in the background?
In the background, BaseX has a query processor which creates an abstract representation of the original query string. By using the -x flag or looking into the GUI query view, you get a glimpse of this structure. So, looking at your original query,
one could get the corresponding "Java translation".
the XQuery string is obviously translated into something that can be interpreted by Java, and you can surely get this representation by looking into our code. Did you try that?