But the indentation is quite different from what I see in Saxon or oXygen output when I indent. You see this with more complex examples.
That’s true, every query processor uses custom indentation algorithms; the specification gives much freedom here [1]. If indentation is important, it’s always recommendable to either preserve the original formatting or use xml:space='preserve' for mixed-context sections.
I’ll never be happy with the decision in XML to lump together indentation of structure and content.
[1] https://www.w3.org/TR/xslt-xquery-serialization-31/#xml-indent