Situation
I'm given multiple XSD-files A.xsd, B.xsd and C.xsd, which reference each others elements via XInclude using IDREF and ID without cyclic dependencies. A.xsd is my root file in the hierarchy.
With XJB and binding files I managed it to generate coherent Java Code from the XSDs.
After successfully creating Java objects a, b and c, I'm trying to marshal them into XML files. This is where i get stuck.
Problem
When marshaling a into a file a.xml, b and c are stored nowhere and a.xml contains no references to them.
How do I store all objects plus references successfully?
Approaches
I have the following approaches at hand, but they are not sutable:
- Including the types of
bandcdirectly in mya.xsdinstead of usingIDREF. Doesn't work because I want multiple XML files at the end. - Write Java code to navigate through the
aobject and find all instances ofbandc. Then marshal allbs andcs spereratly and use XInclude to reference the resulting files. This seems inapproprite, because I don't want my storage mechanism to know all the internals of all classes. I just want to store myaand JAXB marshalling shall handle storing the dependencies on its own as far as possible.
Comparable Questions and Anwsers
The following questions are related to this question, in the point that they want to produce multiple XML files. But none of them considers the information given in the XSD-files and XJC-binding-files and thus require manipulation of the generated java code, some non-trivial programming overhead and some sort of information duplication.