Forums

F.A.Q. F.A.Q.    Register Register    Login Login    Home Home
Search Search
SBML Discussions » jsbml-development » Problem reading history element?
Show: Today's Posts  :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
AuthorTopic
rbyrnes


Posts: 28
Registered:
September 2008
Problem reading history element? 15 Mar '12 14:58 Go to next message

I have a problem getting history elements into my application.

Here is a test file and a test program:

<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
<model id="dd" metaid="_d89fce34-b554-47b8-bac8-cbdc8e4b1515">
<annotation>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description rdf:about="#_d89fce34-b554-47b8-bac8-cbdc8e4b1515">
<dc:creator>
<rdf:Bag>
<rdf:li rdf:parseType="Resource">
<vCard:N rdf:parseType="Resource">
<vCard:Family>aa</vCard:Family>
<vCard:Given>dd</vCard:Given>
</vCard:N>
<vCard:EMAIL>dd</vCard:EMAIL>
<vCard:ORG rdf:parseType="Resource">
<vCard:Orgname>dd</vCard:Orgname>
</vCard:ORG>
</rdf:li>
</rdf:Bag>
</dc:creator>
<dcterms:created rdf:parseType="Resource">
<dcterms:W3CDTF>2012-03-15T21:18:54Z</dcterms:W3CDTF>
</dcterms:created>
<dcterms:modified rdf:parseType="Resource">
<dcterms:W3CDTF>2012-03-15T21:18:54Z</dcterms:W3CDTF>
</dcterms:modified>
</rdf:Description>
</rdf:RDF>
</annotation>
</model>
</sbml>

import java.io.IOException;
import javax.xml.stream.XMLStreamException;
import org.sbml.jsbml.*;

public class ModelHistoryTest
{
public static void main( String[] args )
{
try
{
SBMLReader reader = new SBMLReader( );
SBMLDocument document = null;
try
{
document = reader.readSBMLFromFile( "E:\\testsbml\\testmodelhistory.sbml" );
History mh = document.getModel( ).getHistory( );
int num = mh.getNumCreators( );
System.out.println( "Number of creators: " + num );
}
catch( java.util.EmptyStackException e )
{
throw new IOException( e.getMessage( ) );
}
catch( XMLStreamException x )
{
throw new IOException( x.getMessage( ) );
}
}
catch( Exception ex )
{
ex.printStackTrace( );
}
System.out.println( "Done" );
}
}

The output of the program is

Number of creators: 0
Done

--JavaBob

      
Andreas Dräger


Posts: 273
Registered:
June 2006
Re: Problem reading history element? 19 Mar '12 00:50 Go to previous messageGo to next message

Am 3/16/12 8:12 PM, schrieb rbyrnes:
> I have a problem getting history elements into my application.
>
> Here is a test file and a test program:
>
> <?xml version='1.0' encoding='UTF-8' standalone='no'?>
> <sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
> <model id="dd" metaid="_d89fce34-b554-47b8-bac8-cbdc8e4b1515">
> <annotation>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/">
> <rdf:Description rdf:about="#_d89fce34-b554-47b8-bac8-cbdc8e4b1515">
> <dc:creator>
> <rdf:Bag>
> <rdf:li rdf:parseType="Resource">
> <vCard:N rdf:parseType="Resource">
> <vCard:Family>aa</vCard:Family>
> <vCard:Given>dd</vCard:Given>
> </vCard:N>
> <vCard:EMAIL>dd</vCard:EMAIL>
> <vCard:ORG rdf:parseType="Resource">
> <vCard:Orgname>dd</vCard:Orgname>
> </vCard:ORG>
> </rdf:li>
> </rdf:Bag>
> </dc:creator>
> <dcterms:created rdf:parseType="Resource">
> <dcterms:W3CDTF>2012-03-15T21:18:54Z</dcterms:W3CDTF>
> </dcterms:created>
> <dcterms:modified rdf:parseType="Resource">
> <dcterms:W3CDTF>2012-03-15T21:18:54Z</dcterms:W3CDTF>
> </dcterms:modified>
> </rdf:Description>
> </rdf:RDF>
> </annotation>
> </model>
> </sbml>
>
> import java.io.IOException;
> import javax.xml.stream.XMLStreamException;
> import org.sbml.jsbml.*;
>
> public class ModelHistoryTest
> {
> public static void main( String[] args )
> {
> try
> {
> SBMLReader reader = new SBMLReader( );
> SBMLDocument document = null;
> try
> {
> document = reader.readSBMLFromFile( "E:\\testsbml\\testmodelhistory.sbml" );
> History mh = document.getModel( ).getHistory( );
> int num = mh.getNumCreators( );
> System.out.println( "Number of creators: " + num );
> }
> catch( java.util.EmptyStackException e )
> {
> throw new IOException( e.getMessage( ) );
> }
> catch( XMLStreamException x )
> {
> throw new IOException( x.getMessage( ) );
> }
> }
> catch( Exception ex )
> {
> ex.printStackTrace( );
> }
> System.out.println( "Done" );
> }
> }
>
> The output of the program is
>
> Number of creators: 0
> Done
>
> --JavaBob
>


Dear Robert,

I tested your program with JSBML 0.8 and the current trunk version of
JSBML. In the first case, I also got the result that there are 0
creators and don't know the reason for this at the moment. However, it
seems that this problem has already been solved because in the current
trunk version of JSBML this problem does no longer occur. But if you
checkout the trunk and try to read the identical model, JSBML will
complain that there is an invalid e-mail address field. Furthermore, it
is recommended to parse SBML by using a call like

SBMLDocument document =
SBMLReader.read(ModelHistoryTest.class.getResourceAsStream("testModelHistory.xml"));

which means, please use the static read method instead of instanciating
a new SBMLReader object.

Now, we should have a look for the differences between the 0.8 branch
and the 1.0 trunk version of JSBML and try to figure out why the older
version does not parse the model's history correctly.

Thanks
Andreas

--
Dr. Andreas Dräger
University of Tuebingen
Center for Bioinformatics Tuebingen (ZBIT)
Sand 1
72076 Tübingen
Germany

Phone: +49-7071-29-78982
Fax: +49-7071-29-5091

____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development

For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/

For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu

      
rbyrnes


Posts: 28
Registered:
September 2008
Re: Problem reading history element? 19 Mar '12 09:19 Go to previous messageGo to next message

Andreas-

I tried out the newer code, and also used one of the static methods in Document. The code works much better now.

Thanks!

--JavaBob

      
rbyrnes


Posts: 28
Registered:
September 2008
Re: Problem reading history element? 19 Mar '12 10:49 Go to previous messageGo to next message

Andreas-

I am seeing another problem, while reading histories of non-model elements. Here is a test file, a sample program, and output. I am using a jar file that I compiled from the source code as "jsbml-1.0-a1-with-dependencies.jar".

--JavaBob

<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
<model id="modelid" metaid="_e86152e2-6841-47f9-adb0-434afaa1ecd6">
<annotation>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="#_e86152e2-6841-47f9-adb0-434afaa1ecd6">
<created parseType="Resource">
<W3CDTF>2012-03-19T17:17:33Z</W3CDTF>
</created>
<modified parseType="Resource">
<W3CDTF>2012-03-19T17:17:33Z</W3CDTF>
</modified>
</rdf:Description>
</rdf:RDF>
</annotation>
<listOfCompartments metaid="_ccf85f40-0381-46e0-b111-cba7026bf197">
<annotation>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">
<rdf:Description rdf:about="#_ccf85f40-0381-46e0-b111-cba7026bf197">
<dc:creator>
<Bag>
<li parseType="Resource">
<vCard:N rdf:parseType="Resource">
<vCard:Family>aa</vCard:Family>
<vCard:Given>bb</vCard:Given>
</vCard:N>
<vCard:EMAIL>seymour@ssss.edu</vCard:EMAIL>
<vCard:ORG parseType="Resource">
<vCard:Orgname>ssss</vCard:Orgname>
</vCard:ORG>
</li>
</Bag>
</dc:creator>
</rdf:Description>
</rdf:RDF>
</annotation>
<compartment id="c1" constant="true" metaid="_625b8eb4-f1f7-49fd-99ec-55a68d025df5" size="0">
<annotation>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="#_625b8eb4-f1f7-49fd-99ec-55a68d025df5">
</rdf:Description>
</rdf:RDF>
</annotation>
</compartment>
</listOfCompartments>
</model>
</sbml>

import java.io.*;
import javax.xml.stream.XMLStreamException;
import org.sbml.jsbml.*;

public class TestCompartmentHistory
{
public static void main( String[] args )
{
try
{
File f = null;
SBMLDocument document = null;
try
{
f = new File( "E:\\testsbml\\testcompartmenthistory.sbml" );
document = SBMLReader.read( f );
Model m = document.getModel( );
History c1History = m.getListOfCompartments( ).get( 0 ).getHistory( );
java.util.List<Creator> list = (java.util.List<Creator>) c1History.getListOfCreators( );
System.out.println( "Number of creators: " + list.size( ) );
}
catch( java.util.EmptyStackException e )
{
throw new IOException( e.getMessage( ) );
}
catch( XMLStreamException x )
{
throw new IOException( x.getMessage( ) );
}
}
catch( Exception ex )
{
ex.printStackTrace( );
}
System.out.println( "Done" );
}
}

WARN (VCardParser.java:250) - Lost Information : the element 'N' might be lost as the context object is not a Creator.
WARN (VCardParser.java:131) - Lost Information : the characters '
' on the element 'N' might be lost as the context object is not a Creator.
WARN (VCardParser.java:250) - Lost Information : the element 'Family' might be lost as the context object is not a Creator.
WARN (VCardParser.java:131) - Lost Information : the characters 'aa' on the element 'Family' might be lost as the context object is not a Creator.
WARN (VCardParser.java:250) - Lost Information : the element 'Given' might be lost as the context object is not a Creator.
WARN (VCardParser.java:131) - Lost Information : the characters 'bb' on the element 'Given' might be lost as the context object is not a Creator.
WARN (VCardParser.java:250) - Lost Information : the element 'EMAIL' might be lost as the context object is not a Creator.
WARN (VCardParser.java:131) - Lost Information : the characters 'seymour@ssss.edu' on the element 'EMAIL' might be lost as the context object is not a Creator.
WARN (VCardParser.java:250) - Lost Information : the element 'ORG' might be lost as the context object is not a Creator.
WARN (VCardParser.java:131) - Lost Information : the characters '
' on the element 'ORG' might be lost as the context object is not a Creator.
WARN (VCardParser.java:250) - Lost Information : the element 'Orgname' might be lost as the context object is not a Creator.
WARN (VCardParser.java:131) - Lost Information : the characters 'ssss' on the element 'Orgname' might be lost as the context object is not a Creator.
Number of creators: 0
Done

      
rbyrnes


Posts: 28
Registered:
September 2008
Re: Problem reading history element? 19 Mar '12 12:18 Go to previous messageGo to next message

Andreas-

I am not sure what I did to fix it, but the program works now.

All I did was to comment out some code in Eclipse that was related to RDF annotations but that was unconnected to this test program.

It's quite mysterious.

--JavaBob

      
Andreas Dräger


Posts: 273
Registered:
June 2006
Re: Problem reading history element? 19 Mar '12 23:46 Go to previous messageGo to next message

Am 3/20/12 5:45 AM, schrieb rbyrnes:
> Andreas-
>
> I am not sure what I did to fix it, but the program works now.
>
> All I did was to comment out some code in Eclipse that was related to RDF annotations but that was unconnected to this test program.
>
> It's quite mysterious.
>
> --JavaBob
>
Good morning Robert,

Do you mean, you could fix the problem in the 0.8 branch? If you have a
patch file, I would be very curious to see it.

Thanks
Andreas

--
Dr. Andreas Dräger
University of Tuebingen
Center for Bioinformatics Tuebingen (ZBIT)
Sand 1
72076 Tübingen
Germany

Phone: +49-7071-29-78982
Fax: +49-7071-29-5091

____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development

For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/

For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu

      
Andreas Dräger


Posts: 273
Registered:
June 2006
Re: Problem reading history element? 20 Mar '12 00:27 Go to previous messageGo to next message

Am 3/20/12 5:45 AM, schrieb rbyrnes:
> Andreas-
>
> I am seeing another problem, while reading histories of non-model elements. Here is a test file, a sample program, and output. I am using a jar file that I compiled from the source code as "jsbml-1.0-a1-with-dependencies.jar".
>
> --JavaBob
>
> <?xml version='1.0' encoding='UTF-8' standalone='no'?>
> <sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
> <model id="modelid" metaid="_e86152e2-6841-47f9-adb0-434afaa1ecd6">
> <annotation>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
> <rdf:Description rdf:about="#_e86152e2-6841-47f9-adb0-434afaa1ecd6">
> <created parseType="Resource">
> <W3CDTF>2012-03-19T17:17:33Z</W3CDTF>
> </created>
> <modified parseType="Resource">
> <W3CDTF>2012-03-19T17:17:33Z</W3CDTF>
> </modified>
> </rdf:Description>
> </rdf:RDF>
> </annotation>
> <listOfCompartments metaid="_ccf85f40-0381-46e0-b111-cba7026bf197">
> <annotation>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">
> <rdf:Description rdf:about="#_ccf85f40-0381-46e0-b111-cba7026bf197">
> <dc:creator>
> <Bag>
> <li parseType="Resource">
> <vCard:N rdf:parseType="Resource">
> <vCard:Family>aa</vCard:Family>
> <vCard:Given>bb</vCard:Given>
> </vCard:N>
> <vCard:EMAIL>seymour@ssss.edu</vCard:EMAIL>
> <vCard:ORG parseType="Resource">
> <vCard:Orgname>ssss</vCard:Orgname>
> </vCard:ORG>
> </li>
> </Bag>
> </dc:creator>
> </rdf:Description>
> </rdf:RDF>
> </annotation>
> <compartment id="c1" constant="true" metaid="_625b8eb4-f1f7-49fd-99ec-55a68d025df5" size="0">
> <annotation>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
> <rdf:Description rdf:about="#_625b8eb4-f1f7-49fd-99ec-55a68d025df5">
> </rdf:Description>
> </rdf:RDF>
> </annotation>
> </compartment>
> </listOfCompartments>
> </model>
> </sbml>
>
> import java.io.*;
> import javax.xml.stream.XMLStreamException;
> import org.sbml.jsbml.*;
>
> public class TestCompartmentHistory
> {
> public static void main( String[] args )
> {
> try
> {
> File f = null;
> SBMLDocument document = null;
> try
> {
> f = new File( "E:\\testsbml\\testcompartmenthistory.sbml" );
> document = SBMLReader.read( f );
> Model m = document.getModel( );
> History c1History = m.getListOfCompartments( ).get( 0 ).getHistory( );
> java.util.List<Creator> list = (java.util.List<Creator>) c1History.getListOfCreators( );
> System.out.println( "Number of creators: " + list.size( ) );
> }
> catch( java.util.EmptyStackException e )
> {
> throw new IOException( e.getMessage( ) );
> }
> catch( XMLStreamException x )
> {
> throw new IOException( x.getMessage( ) );
> }
> }
> catch( Exception ex )
> {
> ex.printStackTrace( );
> }
> System.out.println( "Done" );
> }
> }
>
> WARN (VCardParser.java:250) - Lost Information : the element 'N' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters '
> ' on the element 'N' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:250) - Lost Information : the element 'Family' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters 'aa' on the element 'Family' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:250) - Lost Information : the element 'Given' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters 'bb' on the element 'Given' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:250) - Lost Information : the element 'EMAIL' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters 'seymour@ssss.edu' on the element 'EMAIL' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:250) - Lost Information : the element 'ORG' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters '
> ' on the element 'ORG' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:250) - Lost Information : the element 'Orgname' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters 'ssss' on the element 'Orgname' might be lost as the context object is not a Creator.
> Number of creators: 0
> Done
>
>

Hi Robert,

You are right. It seems there is a bug. I modified your program a little
bit and tried to directly read a newly created SBMLDocument again.
Writing works, but reading fails at the moment. It seems there is
something wrong with the history parsing:

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import javax.xml.stream.XMLStreamException;

import org.sbml.jsbml.Creator;
import org.sbml.jsbml.History;
import org.sbml.jsbml.Model;
import org.sbml.jsbml.SBMLDocument;
import org.sbml.jsbml.SBMLReader;
import org.sbml.jsbml.SBMLWriter;

public class TestCompartmentHistory {

public static void main(String[] args) {
try {
SBMLDocument document = new SBMLDocument(3, 1);
Creator creator = new Creator("Andreas", "Draeger", "University
of Tuebingen", "andreas.draeger@uni-tuebingen.de");
document.getHistory().addCreator(creator);
document.createModel("m").getHistory().addCreator(creator.clone());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
SBMLWriter.write(document, stream, ' ', (short) 2);
stream.flush();
System.out.println(stream.toString());
try {
document = SBMLReader.read(stream.toString());
Model m = document.getModel();
History c1History = m.getListOfCompartments().get(0).getHistory();
java.util.List<Creator> list = (java.util.List<Creator>)
c1History.getListOfCreators();
System.out.println("Number of creators: " + list.size());
} catch (java.util.EmptyStackException e) {
throw new IOException(e.getMessage());
} catch (XMLStreamException x) {
throw new IOException(x.getMessage());
}
} catch (Exception ex) {
ex.printStackTrace();
}
System.out.println("Done");
}

}

I suggest to wait for an answer by Nicolas Rodriguez, who implemented
the parsing methods together with Marine Dumousseau.

Cheers
Andreas

--
Dr. Andreas Dräger
University of Tuebingen
Center for Bioinformatics Tuebingen (ZBIT)
Sand 1
72076 Tübingen
Germany

Phone: +49-7071-29-78982
Fax: +49-7071-29-5091

____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development

For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/

For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu

      
rodrigue


Posts: 307
Location:
Cambridge UK
Registered:
February 2005
Re: Problem reading history element? 22 Mar '12 08:09 Go to previous message

The problem is coming from the test file, many namespaces are forgotten.

The following file is working fine :

<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3"
version="1">
<model id="modelid" metaid="_e86152e2-6841-47f9-adb0-434afaa1ecd6">
<annotation>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms/">
<rdf:Description rdf:about="#_e86152e2-6841-47f9-adb0-434afaa1ecd6">
<dcterms:created parseType="Resource">
<dcterms:W3CDTF>2012-03-19T17:17:33Z</dcterms:W3CDTF>
</dcterms:created>
<dcterms:modified parseType="Resource">
<dcterms:W3CDTF>2012-03-19T17:17:33Z</dcterms:W3CDTF>
</dcterms:modified>
</rdf:Description>
</rdf:RDF>
</annotation>
<listOfCompartments metaid="_ccf85f40-0381-46e0-b111-cba7026bf197">
<annotation>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">
<rdf:Description rdf:about="#_ccf85f40-0381-46e0-b111-cba7026bf197">
<dc:creator>
<rdf:Bag>
<rdf:li parseType="Resource">
<vCard:N rdf:parseType="Resource">
<vCard:Family>aa</vCard:Family>
<vCard:Given>bb</vCard:Given>
</vCard:N>
<vCard:EMAIL>seymour@ssss.edu</vCard:EMAIL>
<vCard:ORG parseType="Resource">
<vCard:Orgname>ssss</vCard:Orgname>
</vCard:ORG>
</rdf:li>
</rdf:Bag>
</dc:creator>
</rdf:Description>
</rdf:RDF>
</annotation>
<compartment id="c1" constant="true"
metaid="_625b8eb4-f1f7-49fd-99ec-55a68d025df5" size="0">
<annotation>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="#_625b8eb4-f1f7-49fd-99ec-55a68d025df5">
</rdf:Description>
</rdf:RDF>
</annotation>
</compartment>
</listOfCompartments>
</model>
</sbml>

Cheers,
Nico


On 20/03/12 07:27, Andreas Dräger wrote:
> Am 3/20/12 5:45 AM, schrieb rbyrnes:
>> Andreas-
>>
>> I am seeing another problem, while reading histories of non-model elements. Here is a test file, a sample program, and output. I am using a jar file that I compiled from the source code as "jsbml-1.0-a1-with-dependencies.jar".
>>
>> --JavaBob
>>
>> <?xml version='1.0' encoding='UTF-8' standalone='no'?>
>> <sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
>> <model id="modelid" metaid="_e86152e2-6841-47f9-adb0-434afaa1ecd6">
>> <annotation>
>> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
>> <rdf:Description rdf:about="#_e86152e2-6841-47f9-adb0-434afaa1ecd6">
>> <created parseType="Resource">
>> <W3CDTF>2012-03-19T17:17:33Z</W3CDTF>
>> </created>
>> <modified parseType="Resource">
>> <W3CDTF>2012-03-19T17:17:33Z</W3CDTF>
>> </modified>
>> </rdf:Description>
>> </rdf:RDF>
>> </annotation>
>> <listOfCompartments metaid="_ccf85f40-0381-46e0-b111-cba7026bf197">
>> <annotation>
>> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">
>> <rdf:Description rdf:about="#_ccf85f40-0381-46e0-b111-cba7026bf197">
>> <dc:creator>
>> <Bag>
>> <li parseType="Resource">
>> <vCard:N rdf:parseType="Resource">
>> <vCard:Family>aa</vCard:Family>
>> <vCard:Given>bb</vCard:Given>
>> </vCard:N>
>> <vCard:EMAIL>seymour@ssss.edu</vCard:EMAIL>
>> <vCard:ORG parseType="Resource">
>> <vCard:Orgname>ssss</vCard:Orgname>
>> </vCard:ORG>
>> </li>
>> </Bag>
>> </dc:creator>
>> </rdf:Description>
>> </rdf:RDF>
>> </annotation>
>> <compartment id="c1" constant="true" metaid="_625b8eb4-f1f7-49fd-99ec-55a68d025df5" size="0">
>> <annotation>
>> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
>> <rdf:Description rdf:about="#_625b8eb4-f1f7-49fd-99ec-55a68d025df5">
>> </rdf:Description>
>> </rdf:RDF>
>> </annotation>
>> </compartment>
>> </listOfCompartments>
>> </model>
>> </sbml>
>>
>> import java.io.*;
>> import javax.xml.stream.XMLStreamException;
>> import org.sbml.jsbml.*;
>>
>> public class TestCompartmentHistory
>> {
>> public static void main( String[] args )
>> {
>> try
>> {
>> File f = null;
>> SBMLDocument document = null;
>> try
>> {
>> f = new File( "E:\\testsbml\\testcompartmenthistory.sbml" );
>> document = SBMLReader.read( f );
>> Model m = document.getModel( );
>> History c1History = m.getListOfCompartments( ).get( 0 ).getHistory( );
>> java.util.List<Creator> list = (java.util.List<Creator>) c1History.getListOfCreators( );
>> System.out.println( "Number of creators: " + list.size( ) );
>> }
>> catch( java.util.EmptyStackException e )
>> {
>> throw new IOException( e.getMessage( ) );
>> }
>> catch( XMLStreamException x )
>> {
>> throw new IOException( x.getMessage( ) );
>> }
>> }
>> catch( Exception ex )
>> {
>> ex.printStackTrace( );
>> }
>> System.out.println( "Done" );
>> }
>> }
>>
>> WARN (VCardParser.java:250) - Lost Information : the element 'N' might be lost as the context object is not a Creator.
>> WARN (VCardParser.java:131) - Lost Information : the characters '
>> ' on the element 'N' might be lost as the context object is not a Creator.
>> WARN (VCardParser.java:250) - Lost Information : the element 'Family' might be lost as the context object is not a Creator.
>> WARN (VCardParser.java:131) - Lost Information : the characters 'aa' on the element 'Family' might be lost as the context object is not a Creator.
>> WARN (VCardParser.java:250) - Lost Information : the element 'Given' might be lost as the context object is not a Creator.
>> WARN (VCardParser.java:131) - Lost Information : the characters 'bb' on the element 'Given' might be lost as the context object is not a Creator.
>> WARN (VCardParser.java:250) - Lost Information : the element 'EMAIL' might be lost as the context object is not a Creator.
>> WARN (VCardParser.java:131) - Lost Information : the characters 'seymour@ssss.edu' on the element 'EMAIL' might be lost as the context object is not a Creator.
>> WARN (VCardParser.java:250) - Lost Information : the element 'ORG' might be lost as the context object is not a Creator.
>> WARN (VCardParser.java:131) - Lost Information : the characters '
>> ' on the element 'ORG' might be lost as the context object is not a Creator.
>> WARN (VCardParser.java:250) - Lost Information : the element 'Orgname' might be lost as the context object is not a Creator.
>> WARN (VCardParser.java:131) - Lost Information : the characters 'ssss' on the element 'Orgname' might be lost as the context object is not a Creator.
>> Number of creators: 0
>> Done
>>
>>
> Hi Robert,
>
> You are right. It seems there is a bug. I modified your program a little
> bit and tried to directly read a newly created SBMLDocument again.
> Writing works, but reading fails at the moment. It seems there is
> something wrong with the history parsing:
>
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
>
> import javax.xml.stream.XMLStreamException;
>
> import org.sbml.jsbml.Creator;
> import org.sbml.jsbml.History;
> import org.sbml.jsbml.Model;
> import org.sbml.jsbml.SBMLDocument;
> import org.sbml.jsbml.SBMLReader;
> import org.sbml.jsbml.SBMLWriter;
>
> public class TestCompartmentHistory {
>
> public static void main(String[] args) {
> try {
> SBMLDocument document = new SBMLDocument(3, 1);
> Creator creator = new Creator("Andreas", "Draeger", "University
> of Tuebingen", "andreas.draeger@uni-tuebingen.de");
> document.getHistory().addCreator(creator);
> document.createModel("m").getHistory().addCreator(creator.clone());
> ByteArrayOutputStream stream = new ByteArrayOutputStream();
> SBMLWriter.write(document, stream, ' ', (short) 2);
> stream.flush();
> System.out.println(stream.toString());
> try {
> document = SBMLReader.read(stream.toString());
> Model m = document.getModel();
> History c1History = m.getListOfCompartments().get(0).getHistory();
> java.util.List<Creator> list = (java.util.List<Creator>)
> c1History.getListOfCreators();
> System.out.println("Number of creators: " + list.size());
> } catch (java.util.EmptyStackException e) {
> throw new IOException(e.getMessage());
> } catch (XMLStreamException x) {
> throw new IOException(x.getMessage());
> }
> } catch (Exception ex) {
> ex.printStackTrace();
> }
> System.out.println("Done");
> }
>
> }
>
> I suggest to wait for an answer by Nicolas Rodriguez, who implemented
> the parsing methods together with Marine Dumousseau.
>
> Cheers
> Andreas
>

____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development

For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/

For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu

      
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic:SBML namespace in math elements
Next Topic:Units inheritance in Level 3
Go to forum:
-=] Back to Top [=-

Powered by FUDforum. (Copyright Advanced Internet Designs Inc.)

Please use our issue tracking system for any questions or suggestions about this website.