opensourceBIM / Bcf

1 stars 2 forks source link

xml schema for Project.java #1

Closed muren400 closed 1 year ago

muren400 commented 6 years ago

Hi,

when reading a .bcfzip file containig a project.bcfp file I get following exception. I can't figure out, what I'm doing wrong.

org.opensourcebim.bcf.BcfException: javax.xml.bind.UnmarshalException: unerwartetes Element (URI:"", lokal:"ProjectExtension"). Erwartete Elemente sind <{}project> at org.opensourcebim.bcf.BcfFile.readInternal(BcfFile.java:113) at org.opensourcebim.bcf.BcfFile.read(BcfFile.java:148) at org.opensourcebim.bcf.BcfFile.read(BcfFile.java:59)

The exception occurs on this example: (I renamed it to .zip so i can upload it) test2.bcf.zip

muren400 commented 6 years ago

Ok, I think I found a solution:

When reading the project.bcfp in BcfFile.java (line 124) one should use ProjectExtension instead of Project.

JAXBContext jaxbContext = JAXBContext.newInstance(ProjectExtension.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); ProjectExtension extension = (ProjectExtension) unmarshaller.unmarshal(new FakeClosingInputStream(zipInputStream)); project = extension.getProject();

And the same for write(OutputStream).