This situation comes up often. The technique described here is for DFDL schemas. There's a separate snippet about Combining XML Schemas Together, in case you are working just with XML or have both DFDL-described and XML data in your system.
Q: I have many different DFDL schemas for my different message types. These messages are being mixed together in files. They are prefixed by a 4 byte integer type-code which indicates the specific message format. How can I parse these files?
...