| Author | Topic |
Posts: 307
Location: Cambridge UK
Registered: February 2005
|
|
Re: Problem reading history element?
|
22 Mar '12 08:09
|
 |
|
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
|
|
|