>>> listOfCompartments.add(compartment );
>>> document.getModel().setListOfCompartments(listOfCompartments );
> What happens is that when writing this model to XML the writer does
> not know that you desire to write a compartment of Level 2, it
> therefore only writes the name as this is done in Level 1.
While checking this example in detail I noticed that JSBML adapts the
Level/Version combination when adding elements to that of the parent.
See the method setThisAsParentSBMLObject in AbstractSBase. There you
can see that the method checkLevelAndVersionCompatibility actually
changes the Level/Version combination of an element. This is not done
recursively. To set L/V recursively, we have to set both at the same
time to avoid invalid L/V combinations. However, I am asking myself if
JSBML should be more strict and throw an exception when trying to add
something with different L/V combination to a parent object. What do
Way 1: Silently change the L/V combination in a recursive way
Way 2: Throw an exception.
What is better?
Dr. Andreas Dräger
University of Tuebingen
Center for Bioinformatics Tuebingen (ZBIT)