Simplest solution is to process the documents separately and then run a fourth stylesheet that reads the results (via document()) and merges them appropriately. The pipelining extension may be useful for this purpose, since that would allow it all to happen as a single call to Xalan.
You could try doing something with using "mode" to select which templates are active, and combining the multiple stylesheets into a single file; might be more efficient (depending on what you're doing) but might be harder to maintain.
