I have 3 XSDs linked together:
schema1.xsd
imports namespace="x:y:z" schemaLocation= "schemaDefinitions.xsd"
includes schema2.xsd
schema2.xsd
imports namespace="x:y:z" schemaLocation= "schemaDefinitions.xsd"
includes schema3.xsd
schema3.xsd
imports namespace="x:y:z" schemaLocation= "schemaDefinitions.xsd"
These xsds are provided by an outside source and cannot be changed.
Previously my project used standard JAXB with classes created at compile time. I currently am switching to Dynamic JAXB MOXY (runtime) and now receive the following error on my DynamicJAXBContextFactory.createContextFromXSD() line, which uses schema1.xsd for FileInputStream:
Exception in thread "main" java.lang.ExceptionInInitializerError at
TestTool.JavaRoot.TestTools.MainTool.main(MainTool.java:55)
Caused by: Exception [EclipseLink-50040] (Eclipse Persistence Services -
2.6.2.v20151217-774c696):
org.eclipse.persistence.exceptions.JAXBException
Exception Description: Error creating DynamicJAXBContext.
Internal Exception: org.xml.sax.SAXParseException; systemId:
file:///public/SITE1/config/schema/SchemaDefinitions.xsd; lineNumber:
xyz; columnNumber: xyz; 'xyz' is already defined
I have determined the cause is the fact that all three schemas import schemaDefinitions.xsd. If I remove the import statement from schema2 and schema3 the error is resolved. This error was not present with the previous implementation of jaxb and the xsds have not changed since switching to MOXY.
Questions:
Is it legal/ valid for the xsds to import/ include in this way
What are possible work arounds since I can not modify the XSDs? Perhaps modifications to the bindings xjb file?