entur / netex-java-model

Java JAXB binding classes for NeTEx xsd schema
European Union Public License 1.2
10 stars 13 forks source link

PublicationDeliveryStructure XmlRootElement #2

Closed skinkie closed 6 years ago

skinkie commented 7 years ago

Is there a reason why PublicationDeliveryStructure isn't annotated as XmlRootElement?

csolem commented 7 years ago

We have not intentionally removed the annotation XmlRootElement. It's probably in the nature of XJC and JAXB, as discussed here: http://stackoverflow.com/a/2172942.

We are using the ObjectFactory.createPublicationDelivery when marshalling. See https://github.com/rutebanken/netex-java-model/blob/ddb06368e76bdba39a066d5ea562e970e59f0f4d/src/main/java/org/rutebanken/netex/client/PublicationDeliveryClient.java#L69

skinkie commented 7 years ago

I'm currently using:

File file = new File(fileName);
JAXBContext jaxbContext = JAXBContext.newInstance(PublicationDeliveryStructure.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();

JAXBElement<PublicationDeliveryStructure> publicationDeliveryStructureJAXBElement = (JAXBElement<PublicationDeliveryStructure>) jaxbUnmarshaller.unmarshal(file);
PublicationDeliveryStructure publicationDeliveryStructure = publicationDeliveryStructureJAXBElement.getValue();
csolem commented 7 years ago

Do you get any error messages from executing the code above? (It should also be possible to do JAXBElement<PublicationDeliveryStructure> jaxbElement = jaxbUnmarshaller.unmarshal(new StreamSource(file), PublicationDeliveryStructure.class); do avoid the cast)