Attempting to analyze schema documents in XSLT is a fairly challenging undertaking. I would suggest a multi-pass approach, for example the first pass should follow the "include" links to create a single document containing a module and everything it includes and imports. Then you can define keys on this document to retrieve objects such as complex types by name. You will need to handle QNames properly - the simplest way of doing this is to make your stylesheet schema-aware (using the schema-for-schemas S4S as the input schema) and then the QNames will match up automatically.
Really your question is a very open-ended one. If there's a specific problem you're having with code that doesn't work, we can probably help you solve it; but the overall design of what you're doing is too big a task to tackle in a simple response like this.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference