package JAXBmondial;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.io.File;

public class JAXBmondialExt {
 public static void main (String args[]) { try {
  JAXBContext jc = JAXBContext.newInstance("JAXBmondial");
  Unmarshaller unm = jc.createUnmarshaller();
  unm.setProperty("com.sun.xml.bind.ObjectFactory", new MondialObjectFactory()); // <<<<
  Mondial mondial = (Mondial) unm.unmarshal(new File("mondial-jaxb.xml"));

  for ( Country x : mondial.getCountry() ) {  // <<<<<<<  only "Country" possible
    MyCountry country  = (MyCountry) x;   // <<<<<<<<<
    System.out.println("Country: " + country.getName()  );
    country.printCityNames();  // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  }} catch (Exception e ) { e.printStackTrace(); }
}}
