However (this is a separate bug), the document-node() parent/child ordering is messed up:
I just noticed that I unwittingly ignored your second remark. I’ll have a look at this issue soon (it could be related to issue 588 [1], which was recently brought up by Hans-Jürgen Rennau on this list [2]).
[1] https://mailman.uni-konstanz.de/pipermail/basex-talk/2012-October/004035.htm... [2] https://github.com/BaseXdb/basex/issues/588