I import the above schema into EMF and then use the "Export Model..." to
generate create UML. In addition to issues previously mentioned (for which
I have submitted bug reports), I am running into a problem when I want to
go back to EMF from UML. Ideally, I would like to add OCL constraints to
the UML and then import back into EMF. This part seems to work fine. The
issue I am having is related to serializing to XML. Using the following
test code:
Book book = LibraryFactory.eINSTANCE.createBook();
book.setAuthor(author);
book.setCategory(BookCategory.SCIENCE_FICTION);
book.setTitle("Some Title");
book.setPages(100);
I get a NullPointerException, that I have tracked down to differences
between XSD->EMF and XSD->EMF->UML->EMF generated code. Specifically, in
LibraryPackageImpl.java, the following line:
In the working ocde, the upperBound parameter is set to -2 (unspecified)
and the isContainment parameter is set to IS_COMPOSITE.
In the non-working code, the upperBound parameter is set to 1 and the
isContaintment parameter is set to !IS_COMPOSITE.
The upperBound parameter doesn't make a difference. However, if I change
!IS_COMPOSITE to IS_COMPOSITE in the non-working code, I no longer get a
null pointer exception. IS_COMPOSITE, should be true as the UML model
shows property "Aggregation" as "Composite" for the DocumentRoot.library
property. Not sure why it gets set the way it does. Any ideas?