how to print QueryInfo through Java API ?
The -V flag or the QUERYINFO option are alternatives; please find more information in the documentation.
"transaction/* except (/transaction/traInfo)"
You could try to rewrite this to...
transaction/* except traInfo
...or...
let $traInfo := /transaction/traInfo return transaction/* except $traInfo
...or...
transaction/*[name() ne 'traInfo']