Reputation: 394
I have two eclipselink moxy binding files because I want to add binding metadata for classes coming from two different packages. The problem is, that I want to refer to an xml-element
defined in binding xml file B.xml
from an xml-element-ref
defined in binding xml file A.xml
.
How could I solve this problem?
Upvotes: 1
Views: 240
Reputation: 149037
There is nothing special that needs to be done. Just make sure when you bootstrap the MOXy JAXBContext
that you bring in both external mapping documents. See below for an example:
package forum10874711;
import java.util.*;
import javax.xml.bind.*;
import org.eclipse.persistence.jaxb.JAXBContextFactory;
import forum10874711.b.B;
public class Demo2 {
public static void main(String[] args) throws Exception {
Map<String, Object> properties = new HashMap<String, Object>(1);
List<String> metadata = new ArrayList<String>(2);
metadata.add("forum10874711/a/binding2.xml");
metadata.add("forum10874711/b/binding2.xml");
properties.put(JAXBContextFactory.ECLIPSELINK_OXM_XML_KEY, metadata);
JAXBContext jc = JAXBContext.newInstance(new Class[] {B.class}, properties);
}
}
Note:
The above code was taken from my answer to one of your other questions (that includes a full example):
Upvotes: 1