Each xs:schema
element contains declarations for just one target namespace. But nothing in the spec says that xs:schema
has to be the root element of the XML document. In theory, therefore, you could just wrap both schema elements in a wrapper file; in practice, not all XSD validators will be happy with that as input.
[Later addition: since it seems to be a contentious point, perhaps I should say explicitly that I'm assuming that by "one XSD file" you mean one XML document, contained in a single file, containing the XSD. If you mean something else, please explain.]
You don't say what kind of problems you're having with imports, but one thing that may be worth trying is to remove the schema location information from the xs:import
element in A.xsd (so the import just names the namespace involved, not the location of the schema document), and pass both A.xsd and B.xsd to the processor as run-time parameters. (Most though not all XSD processors allow you to specify at invocation time some schema documents for them to read. The order of the arguments can matter, so if it doesn't work the first time, try reversing the order.)