>In some case, it's even not possible because the optimizer creates new expressions that have no counterpart in the original XQuery language
Do you mean they invoke internal BaseX functions? Also to help me understand what BaseX optimization involves:
If these serializations are post optimization does mean they MAY embody assumptions about the context that are only valid at the moment they were made? Or could one expect to be able to deserialize them later and always get the same answers the original xquery would generate?
/Andy