addChild() public method

public addChild ( XMLNode node ) : int
node XMLNode
return int
 public void test_Node_clone()
 {
     XMLAttributes att = new XMLAttributes();
       XMLTriple t = new XMLTriple("sarah", "http://foo.org/", "bar");
       XMLToken token = new XMLToken(t,att,3,4);
       XMLNode node = new XMLNode(token);
       XMLNode child = new XMLNode();
       node.addChild(child);
       assertTrue( node.getNumChildren() == 1 );
       assertTrue( node.getName() ==  "sarah" );
       assertTrue( node.getURI() ==  "http://foo.org/" );
       assertTrue( node.getPrefix() ==  "bar" );
       assertTrue( node.isEnd() == false );
       assertTrue( node.isEOF() == false );
       assertTrue( node.getLine() == 3 );
       assertTrue( node.getColumn() == 4 );
       XMLNode node2 = (XMLNode) node.clone();
       assertTrue( node2.getNumChildren() == 1 );
       assertTrue( node2.getName() ==  "sarah" );
       assertTrue( node2.getURI() ==  "http://foo.org/" );
       assertTrue( node2.getPrefix() ==  "bar" );
       assertTrue( node2.isEnd() == false );
       assertTrue( node2.isEOF() == false );
       assertTrue( node2.getLine() == 3 );
       assertTrue( node2.getColumn() == 4 );
       t = null;
       token = null;
       node = null;
       node2 = null;
 }
 public void test_XMLNode_addChild1()
 {
     XMLNode node = new XMLNode();
       XMLNode node2 = new XMLNode();
       int i = node.addChild(node2);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( node.getNumChildren() == 1 );
       node = null;
       node2 = null;
 }
 public void test_XMLNode_addChild3()
 {
     XMLTriple triple = new  XMLTriple("test","","");
       XMLNode node = new XMLNode(triple);
       XMLNode node2 = new XMLNode();
       int i = node.addChild(node2);
       assertTrue( i == libsbml.LIBSBML_INVALID_XML_OPERATION );
       assertTrue( node.getNumChildren() == 0 );
       triple = null;
       node = null;
       node2 = null;
 }
 public void test_XMLNode_addChild2()
 {
     XMLTriple triple = new  XMLTriple("test","","");
       XMLAttributes attr = new  XMLAttributes();
       XMLNode node = new XMLNode(triple,attr);
       XMLNode node2 = new XMLNode();
       int i = node.addChild(node2);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( node.getNumChildren() == 1 );
       triple = null;
       attr = null;
       node = null;
       node2 = null;
 }
 public void test_SyntaxChecker_validXHTML()
 {
     SBMLNamespaces NS24 = new  SBMLNamespaces(2,4);
       SBMLNamespaces NS31 = new  SBMLNamespaces(3,1);
       XMLToken toptoken;
       XMLNode topnode;
       XMLTriple toptriple = new  XMLTriple("notes", "", "");
       XMLToken token;
       XMLNode node;
       XMLTriple triple = new  XMLTriple("p", "", "");
       XMLAttributes att = new  XMLAttributes();
       XMLNamespaces ns = new  XMLNamespaces();
       ns.add( "http://www.w3.org/1999/xhtml", "");
       XMLToken tt = new  XMLToken("This is my text");
       XMLNode n1 = new XMLNode(tt);
       toptoken = new  XMLToken(toptriple,att);
       topnode = new XMLNode(toptoken);
       token = new  XMLToken(triple,att,ns);
       node = new XMLNode(token);
       node.addChild(n1);
       topnode.addChild(node);
       assertTrue( SyntaxChecker.hasExpectedXHTMLSyntax(topnode,null) == true );
       assertTrue( SyntaxChecker.hasExpectedXHTMLSyntax(topnode,NS24) == true );
       assertTrue( SyntaxChecker.hasExpectedXHTMLSyntax(topnode,NS31) == true );
       triple = new  XMLTriple("html", "", "");
       token = new  XMLToken(triple,att,ns);
       node = new XMLNode(token);
       node.addChild(n1);
       topnode.removeChild(0);
       topnode.addChild(node);
       assertTrue( SyntaxChecker.hasExpectedXHTMLSyntax(topnode,null) == true );
       assertTrue( SyntaxChecker.hasExpectedXHTMLSyntax(topnode,NS24) == false );
       assertTrue( SyntaxChecker.hasExpectedXHTMLSyntax(topnode,NS31) == true );
       triple = new  XMLTriple("html", "", "");
       ns.clear();
       token = new  XMLToken(triple,att,ns);
       node = new XMLNode(token);
       node.addChild(n1);
       topnode.removeChild(0);
       topnode.addChild(node);
       assertTrue( SyntaxChecker.hasExpectedXHTMLSyntax(topnode,null) == false );
       assertTrue( SyntaxChecker.hasExpectedXHTMLSyntax(topnode,NS24) == false );
       assertTrue( SyntaxChecker.hasExpectedXHTMLSyntax(topnode,NS31) == false );
 }
Example #6
0
 public void test_CVTerm_createFromNode()
 {
     XMLAttributes xa;
       XMLTriple qual_triple = new  XMLTriple("is", "", "bqbiol");
       XMLTriple bag_triple = new  XMLTriple();
       XMLTriple li_triple = new  XMLTriple();
       XMLAttributes att = new  XMLAttributes();
       att.add( "", "This is my resource");
       XMLAttributes att1 = new  XMLAttributes();
       XMLToken li_token = new  XMLToken(li_triple,att);
       XMLToken bag_token = new  XMLToken(bag_triple,att1);
       XMLToken qual_token = new  XMLToken(qual_triple,att1);
       XMLNode li = new XMLNode(li_token);
       XMLNode bag = new XMLNode(bag_token);
       XMLNode node = new XMLNode(qual_token);
       bag.addChild(li);
       node.addChild(bag);
       CVTerm term = new  CVTerm(node);
       assertTrue( term != null );
       assertTrue( term.getQualifierType() == libsbml.BIOLOGICAL_QUALIFIER );
       assertTrue( term.getBiologicalQualifierType() == libsbml.BQB_IS );
       xa = term.getResources();
       assertTrue( xa.getLength() == 1 );
       assertTrue((  "rdf:resource" == xa.getName(0) ));
       assertTrue((  "This is my resource" == xa.getValue(0) ));
       qual_triple = null;
       bag_triple = null;
       li_triple = null;
       li_token = null;
       bag_token = null;
       qual_token = null;
       att = null;
       att1 = null;
       term = null;
       node = null;
       bag = null;
       li = null;
 }
 public void test_SBase_appendNotes8()
 {
     XMLAttributes att = new  XMLAttributes();
       XMLNamespaces ns = new  XMLNamespaces();
       ns.add( "http://www.w3.org/1999/xhtml", "");
       XMLTriple body_triple = new  XMLTriple("body", "", "");
       XMLTriple p_triple = new  XMLTriple("p", "", "");
       XMLToken body_token = new  XMLToken(body_triple,att,ns);
       XMLToken p_token = new  XMLToken(p_triple,att);
       XMLToken text_token = new  XMLToken("This is my text");
       XMLNode body_node = new XMLNode(body_token);
       XMLNode p_node = new XMLNode(p_token);
       XMLNode text_node = new XMLNode(text_token);
       XMLToken p_token1 = new  XMLToken(p_triple,att,ns);
       XMLToken text_token1 = new  XMLToken("This is more text");
       XMLNode p_node1 = new XMLNode(p_token1);
       XMLNode text_node1 = new XMLNode(text_token1);
       XMLNode notes;
       XMLNode child, child1;
       p_node.addChild(text_node);
       body_node.addChild(p_node);
       p_node1.addChild(text_node1);
       int i = S.setNotes(body_node);
       i = S.appendNotes(p_node1);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       notes = S.getNotes();
       assertTrue((  "notes" == notes.getName() ));
       assertTrue( notes.getNumChildren() == 1 );
       child = notes.getChild(0);
       assertTrue((  "body" == child.getName() ));
       assertTrue( child.getNumChildren() == 2 );
       child1 = child.getChild(0);
       assertTrue((  "p" == child1.getName() ));
       assertTrue( child1.getNumChildren() == 1 );
       child1 = child1.getChild(0);
       assertTrue((  "This is my text" == child1.getCharacters() ));
       assertTrue( child1.getNumChildren() == 0 );
       child1 = child.getChild(1);
       assertTrue((  "p" == child1.getName() ));
       assertTrue( child1.getNumChildren() == 1 );
       child1 = child1.getChild(0);
       assertTrue((  "This is more text" == child1.getCharacters() ));
       assertTrue( child1.getNumChildren() == 0 );
       att = null;
       ns = null;
       body_triple = null;
       p_triple = null;
       body_token = null;
       p_token = null;
       text_token = null;
       text_token1 = null;
       p_token1 = null;
       body_node = null;
       p_node = null;
       text_node = null;
       p_node1 = null;
       text_node1 = null;
 }
 public void test_SBase_appendNotes()
 {
     XMLToken token;
       XMLNode node;
       XMLToken token1;
       XMLNode node1;
       XMLNode node2;
       XMLTriple triple = new  XMLTriple("p", "", "");
       XMLAttributes att = new  XMLAttributes();
       XMLNamespaces ns = new  XMLNamespaces();
       ns.add( "http://www.w3.org/1999/xhtml", "");
       XMLToken token4 = new  XMLToken("This is my text");
       XMLNode node4 = new XMLNode(token4);
       XMLToken token5 = new  XMLToken("This is additional text");
       XMLNode node5 = new XMLNode(token5);
       token = new  XMLToken(triple,att,ns);
       node = new XMLNode(token);
       node.addChild(node4);
       int i = S.setNotes(node);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( S.isSetNotes() == true );
       token1 = new  XMLToken(triple,att,ns);
       node1 = new XMLNode(token1);
       node1.addChild(node5);
       i = S.appendNotes(node1);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( S.isSetNotes() == true );
       node2 = S.getNotes();
       assertTrue( node2.getNumChildren() == 2 );
       assertTrue((  "p" == node2.getChild(0).getName() ));
       assertTrue( node2.getChild(0).getNumChildren() == 1 );
       assertTrue((  "p" == node2.getChild(1).getName() ));
       assertTrue( node2.getChild(1).getNumChildren() == 1 );
       string chars1 = node2.getChild(0).getChild(0).getCharacters();
       string chars2 = node2.getChild(1).getChild(0).getCharacters();
       assertTrue((  "This is my text" == chars1 ));
       assertTrue((  "This is additional text" == chars2 ));
       node = null;
       node1 = null;
 }
 public void test_SBase_appendAnnotationString()
 {
     XMLToken token;
       XMLNode node;
       token = new  XMLToken("This is a test note");
       node = new XMLNode(token);
       XMLToken token_top;
       XMLNode node_top;
       XMLTriple triple = new XMLTriple("any", "", "pr");
       XMLAttributes att = new XMLAttributes();
       XMLNamespaces ns = new XMLNamespaces();
       ns.add("http://www.any", "pr");
       token_top = new XMLToken(triple, att, ns);
       node_top = new XMLNode(token_top);
       node_top.addChild(node);
       int i = S.setAnnotation(node_top);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       i = S.appendAnnotation("<prA:other xmlns:prA=\"http://some\">This is additional</prA:other>");
       XMLNode t1 = S.getAnnotation();
       assertTrue( t1.getNumChildren() == 2 );
       assertTrue((     "This is a test note" == t1.getChild(0).getChild(0).getCharacters() ));
       XMLNode c1 = t1.getChild(1);
       assertTrue( c1.getNumChildren() == 1 );
       assertTrue((  "This is additional" == c1.getChild(0).getCharacters() ));
 }
 public void test_SBase_setNotes1()
 {
     XMLAttributes att = new  XMLAttributes();
       XMLNamespaces ns = new  XMLNamespaces();
       ns.add( "http://www.w3.org/1999/xhtml", "");
       XMLTriple html_triple = new  XMLTriple("html", "", "");
       XMLTriple head_triple = new  XMLTriple("head", "", "");
       XMLTriple title_triple = new  XMLTriple("title", "", "");
       XMLTriple body_triple = new  XMLTriple("body", "", "");
       XMLTriple p_triple = new  XMLTriple("p", "", "");
       XMLToken html_token = new  XMLToken(html_triple,att,ns);
       XMLToken head_token = new  XMLToken(head_triple,att);
       XMLToken title_token = new  XMLToken(title_triple,att);
       XMLToken body_token = new  XMLToken(body_triple,att);
       XMLToken p_token = new  XMLToken(p_triple,att);
       XMLToken text_token = new  XMLToken("This is my text");
       XMLNode html_node = new XMLNode(html_token);
       XMLNode head_node = new XMLNode(head_token);
       XMLNode title_node = new XMLNode(title_token);
       XMLNode body_node = new XMLNode(body_token);
       XMLNode p_node = new XMLNode(p_token);
       XMLNode text_node = new XMLNode(text_token);
       XMLNode notes;
       XMLNode child;
       p_node.addChild(text_node);
       body_node.addChild(p_node);
       head_node.addChild(title_node);
       html_node.addChild(head_node);
       html_node.addChild(body_node);
       int i = S.setNotes(html_node);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       notes = S.getNotes();
       assertTrue((  "notes" == notes.getName() ));
       assertTrue( notes.getNumChildren() == 1 );
       child = notes.getChild(0);
       assertTrue((  "html" == child.getName() ));
       assertTrue( child.getNumChildren() == 2 );
       child = child.getChild(1);
       assertTrue((  "body" == child.getName() ));
       assertTrue( child.getNumChildren() == 1 );
       child = child.getChild(0);
       assertTrue((  "p" == child.getName() ));
       assertTrue( child.getNumChildren() == 1 );
       child = child.getChild(0);
       assertTrue((  "This is my text" == child.getCharacters() ));
       assertTrue( child.getNumChildren() == 0 );
       att = null;
       ns = null;
       html_triple = null;
       head_triple = null;
       body_triple = null;
       p_triple = null;
       html_token = null;
       head_token = null;
       body_token = null;
       p_token = null;
       text_token = null;
       html_node = null;
       head_node = null;
       body_node = null;
       p_node = null;
       text_node = null;
 }
 public void test_SBase_setNotes()
 {
     XMLToken token;
       XMLNode node;
       XMLTriple triple = new  XMLTriple("p", "", "");
       XMLAttributes att = new  XMLAttributes();
       XMLNamespaces ns = new  XMLNamespaces();
       ns.add( "http://www.w3.org/1999/xhtml", "");
       XMLToken tt = new  XMLToken("This is my text");
       XMLNode n1 = new XMLNode(tt);
       token = new  XMLToken(triple,att,ns);
       node = new XMLNode(token);
       node.addChild(n1);
       int i = S.setNotes(node);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( S.isSetNotes() == true );
       i = S.unsetNotes();
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( S.isSetNotes() == false );
       token = new  XMLToken("This is a test note");
       node = new XMLNode(token);
       i = S.setNotes(node);
       assertTrue( i == libsbml.LIBSBML_INVALID_OBJECT );
       assertTrue( S.isSetNotes() == false );
       token = new  XMLToken(triple,att,ns);
       node = new XMLNode(token);
       node.addChild(n1);
       i = S.setNotes(node);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( S.isSetNotes() == true );
       i = S.setNotes((XMLNode)null);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( S.isSetNotes() == false );
       node = null;
 }
 public void test_WriteSBML_Constraint_full()
 {
     D.setLevelAndVersion(2,2,false);
       string expected = "<constraint sboTerm=\"SBO:0000064\">\n" +
     "  <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n" +
     "    <apply>\n" +
     "      <leq/>\n" +
     "      <ci> P1 </ci>\n" +
     "      <ci> t </ci>\n" +
     "    </apply>\n" +
     "  </math>\n" +
     "  <message>\n" +
     "    <p xmlns=\"http://www.w3.org/1999/xhtml\"> Species P1 is out of range </p>\n" +
     "  </message>\n" +
     "</constraint>";
       Constraint c = D.createModel().createConstraint();
       ASTNode node = libsbml.parseFormula("leq(P1,t)");
       c.setMath(node);
       c.setSBOTerm(64);
       XMLNode text = XMLNode.convertStringToXMLNode(" Species P1 is out of range ");
       XMLTriple triple = new XMLTriple("p", "http://www.w3.org/1999/xhtml", "");
       XMLAttributes att = new XMLAttributes();
       XMLNamespaces xmlns = new XMLNamespaces();
       xmlns.add("http://www.w3.org/1999/xhtml");
       XMLNode p = new XMLNode(triple,att,xmlns);
       p.addChild(text);
       XMLTriple triple1 = new XMLTriple("message", "", "");
       XMLAttributes att1 = new XMLAttributes();
       XMLNode message = new XMLNode(triple1,att1);
       message.addChild(p);
       c.setMessage(message);
       assertEquals( true, equals(expected,c.toSBML()) );
 }
 public void test_XMLNode_insert()
 {
     XMLAttributes attr = new  XMLAttributes();
       XMLTriple trp_p = new  XMLTriple("parent","","");
       XMLTriple trp_c1 = new  XMLTriple("child1","","");
       XMLTriple trp_c2 = new  XMLTriple("child2","","");
       XMLTriple trp_c3 = new  XMLTriple("child3","","");
       XMLTriple trp_c4 = new  XMLTriple("child4","","");
       XMLTriple trp_c5 = new  XMLTriple("child5","","");
       XMLNode p = new XMLNode(trp_p,attr);
       XMLNode c1 = new XMLNode(trp_c1,attr);
       XMLNode c2 = new XMLNode(trp_c2,attr);
       XMLNode c3 = new XMLNode(trp_c3,attr);
       XMLNode c4 = new XMLNode(trp_c4,attr);
       XMLNode c5 = new XMLNode(trp_c5,attr);
       p.addChild(c2);
       p.addChild(c4);
       p.insertChild(0,c1);
       p.insertChild(2,c3);
       p.insertChild(4,c5);
       assertTrue( p.getNumChildren() == 5 );
       assertTrue( (  "child1" != p.getChild(0).getName() ) == false );
       assertTrue( (  "child2" != p.getChild(1).getName() ) == false );
       assertTrue( (  "child3" != p.getChild(2).getName() ) == false );
       assertTrue( (  "child4" != p.getChild(3).getName() ) == false );
       assertTrue( (  "child5" != p.getChild(4).getName() ) == false );
       p.removeChildren();
       p.insertChild(0,c1);
       p.insertChild(0,c2);
       p.insertChild(0,c3);
       p.insertChild(0,c4);
       p.insertChild(0,c5);
       assertTrue( p.getNumChildren() == 5 );
       assertTrue( (  "child5" != p.getChild(0).getName() ) == false );
       assertTrue( (  "child4" != p.getChild(1).getName() ) == false );
       assertTrue( (  "child3" != p.getChild(2).getName() ) == false );
       assertTrue( (  "child2" != p.getChild(3).getName() ) == false );
       assertTrue( (  "child1" != p.getChild(4).getName() ) == false );
       p.removeChildren();
       p.insertChild(1,c1);
       p.insertChild(2,c2);
       p.insertChild(3,c3);
       p.insertChild(4,c4);
       p.insertChild(5,c5);
       assertTrue( p.getNumChildren() == 5 );
       assertTrue( (  "child1" != p.getChild(0).getName() ) == false );
       assertTrue( (  "child2" != p.getChild(1).getName() ) == false );
       assertTrue( (  "child3" != p.getChild(2).getName() ) == false );
       assertTrue( (  "child4" != p.getChild(3).getName() ) == false );
       assertTrue( (  "child5" != p.getChild(4).getName() ) == false );
       p.removeChildren();
       XMLNode tmp;
       tmp = p.insertChild(0,c1);
       assertTrue( ( "child1" != tmp.getName() ) == false );
       tmp = p.insertChild(0,c2);
       assertTrue( ( "child2" != tmp.getName() ) == false );
       tmp = p.insertChild(0,c3);
       assertTrue( ( "child3" != tmp.getName() ) == false );
       tmp = p.insertChild(0,c4);
       assertTrue( ( "child4" != tmp.getName() ) == false );
       tmp = p.insertChild(0,c5);
       assertTrue( ( "child5" != tmp.getName() ) == false );
       p.removeChildren();
       tmp = p.insertChild(1,c1);
       assertTrue( ( "child1" != tmp.getName() ) == false );
       tmp = p.insertChild(2,c2);
       assertTrue( ( "child2" != tmp.getName() ) == false );
       tmp = p.insertChild(3,c3);
       assertTrue( ( "child3" != tmp.getName() ) == false );
       tmp = p.insertChild(4,c4);
       assertTrue( ( "child4" != tmp.getName() ) == false );
       tmp = p.insertChild(5,c5);
       assertTrue( ( "child5" != tmp.getName() ) == false );
       p = null;
       c1 = null;
       c2 = null;
       c3 = null;
       c4 = null;
       c5 = null;
       attr = null;
       trp_p = null;
       trp_c1 = null;
       trp_c2 = null;
       trp_c3 = null;
       trp_c4 = null;
       trp_c5 = null;
 }
 public void test_SBase_appendAnnotation()
 {
     XMLToken token;
       XMLNode node;
       XMLToken token1;
       XMLNode node1;
       XMLToken token_top;
       XMLNode node_top;
       XMLTriple triple = new XMLTriple("any", "", "pr");
       XMLAttributes att = new XMLAttributes();
       XMLNamespaces ns = new XMLNamespaces();
       ns.add("http://www.any", "pr");
       XMLToken token_top1;
       XMLNode node_top1;
       XMLTriple triple1 = new XMLTriple("anyOther", "", "prOther");
       XMLNamespaces ns1 = new XMLNamespaces();
       ns1.add("http://www.any.other", "prOther");
       token = new XMLToken("This is a test note");
       node = new XMLNode(token);
       token1 = new  XMLToken("This is additional");
       node1 = new XMLNode(token1);
       token_top = new XMLToken(triple, att, ns);
       node_top = new XMLNode(token_top);
       node_top.addChild(node);
       token_top1 = new XMLToken(triple1, att, ns1);
       node_top1 = new XMLNode(token_top1);
       node_top1.addChild(node1);
       int i = S.setAnnotation(node_top);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       i = S.appendAnnotation(node_top1);
       XMLNode t1 = S.getAnnotation();
       assertTrue( t1.getNumChildren() == 2 );
       assertTrue((     "This is a test note" == t1.getChild(0).getChild(0).getCharacters() ));
       assertTrue((     "This is additional" == t1.getChild(1).getChild(0).getCharacters() ));
 }
Example #15
0
 public void test_SBase_appendNotes5()
 {
     XMLAttributes att = new XMLAttributes ();
     XMLNamespaces ns = new XMLNamespaces ();
     ns.@add ("http://www.w3.org/1999/xhtml", "");
     XMLTriple html_triple = new XMLTriple ("html", "", "");
     XMLTriple head_triple = new XMLTriple ("head", "", "");
     XMLTriple title_triple = new XMLTriple ("title", "", "");
     XMLTriple body_triple = new XMLTriple ("body", "", "");
     XMLTriple p_triple = new XMLTriple ("p", "", "");
     XMLToken html_token = new XMLToken (html_triple, att, ns);
     XMLToken head_token = new XMLToken (head_triple, att);
     XMLToken title_token = new XMLToken (title_triple, att);
     XMLToken body_token = new XMLToken (body_triple, att);
     XMLToken p_token = new XMLToken (p_triple, att);
     XMLToken p_token1 = new XMLToken (p_triple, att, ns);
     XMLToken text_token = new XMLToken ("This is my text");
     XMLNode p_node = new XMLNode (p_token1);
     XMLNode text_node = new XMLNode (text_token);
     XMLToken text_token1 = new XMLToken ("This is more text");
     XMLNode html_node1 = new XMLNode (html_token);
     XMLNode head_node1 = new XMLNode (head_token);
     XMLNode title_node1 = new XMLNode (title_token);
     XMLNode body_node1 = new XMLNode (body_token);
     XMLNode p_node1 = new XMLNode (p_token);
     XMLNode text_node1 = new XMLNode (text_token1);
     XMLNode notes;
     XMLNode child, child1;
     p_node.addChild (text_node);
     p_node1.addChild (text_node1);
     body_node1.addChild (p_node1);
     head_node1.addChild (title_node1);
     html_node1.addChild (head_node1);
     html_node1.addChild (body_node1);
     S.setNotes (p_node);
     S.appendNotes (html_node1);
     notes = S.getNotes ();
     assertTrue (("notes" == notes.getName ()));
     assertTrue (notes.getNumChildren () == 1);
     child = notes.getChild (0);
     assertTrue (("html" == child.getName ()));
     assertTrue (child.getNumChildren () == 2);
     child = child.getChild (1);
     assertTrue (("body" == child.getName ()));
     assertTrue (child.getNumChildren () == 2);
     child1 = child.getChild (0);
     assertTrue (("p" == child1.getName ()));
     assertTrue (child1.getNumChildren () == 1);
     child1 = child1.getChild (0);
     assertTrue (("This is my text" == child1.getCharacters ()));
     assertTrue (child1.getNumChildren () == 0);
     child1 = child.getChild (1);
     assertTrue (("p" == child1.getName ()));
     assertTrue (child1.getNumChildren () == 1);
     child1 = child1.getChild (0);
     assertTrue (("This is more text" == child1.getCharacters ()));
     assertTrue (child1.getNumChildren () == 0);
     att = null;
     ns = null;
     html_triple = null;
     head_triple = null;
     body_triple = null;
     p_triple = null;
     body_token = null;
     p_token = null;
     p_token1 = null;
     text_token = null;
     text_token1 = null;
     p_node = null;
     text_node = null;
     html_node1 = null;
     head_node1 = null;
     body_node1 = null;
     p_node1 = null;
     text_node1 = null;
 }
 public void test_XMLNode_remove()
 {
     XMLAttributes attr = new  XMLAttributes();
       XMLTriple trp_p = new  XMLTriple("parent","","");
       XMLTriple trp_c1 = new  XMLTriple("child1","","");
       XMLTriple trp_c2 = new  XMLTriple("child2","","");
       XMLTriple trp_c3 = new  XMLTriple("child3","","");
       XMLTriple trp_c4 = new  XMLTriple("child4","","");
       XMLTriple trp_c5 = new  XMLTriple("child5","","");
       XMLNode p = new XMLNode(trp_p,attr);
       XMLNode c1 = new XMLNode(trp_c1,attr);
       XMLNode c2 = new XMLNode(trp_c2,attr);
       XMLNode c3 = new XMLNode(trp_c3,attr);
       XMLNode c4 = new XMLNode(trp_c4,attr);
       XMLNode c5 = new XMLNode(trp_c5,attr);
       XMLNode r;
       p.addChild(c1);
       p.addChild(c2);
       p.addChild(c3);
       p.addChild(c4);
       p.addChild(c5);
       r = p.removeChild(5);
       assertTrue( r == null );
       r = p.removeChild(1);
       assertTrue( p.getNumChildren() == 4 );
       assertTrue( ( "child2" != r.getName() ) == false );
       r = null;
       r = p.removeChild(3);
       assertTrue( p.getNumChildren() == 3 );
       assertTrue( ( "child5" != r.getName() ) == false );
       r = null;
       r = p.removeChild(0);
       assertTrue( p.getNumChildren() == 2 );
       assertTrue( ( "child1" != r.getName() ) == false );
       r = null;
       r = p.removeChild(1);
       assertTrue( p.getNumChildren() == 1 );
       assertTrue( ( "child4" != r.getName() ) == false );
       r = null;
       r = p.removeChild(0);
       assertTrue( p.getNumChildren() == 0 );
       assertTrue( ( "child3" != r.getName() ) == false );
       r = null;
       p.addChild(c1);
       p.addChild(c2);
       p.addChild(c3);
       p.addChild(c4);
       p.addChild(c5);
       r = p.removeChild(4);
       assertTrue( p.getNumChildren() == 4 );
       assertTrue( ( "child5" != r.getName() ) == false );
       r = null;
       r = p.removeChild(3);
       assertTrue( p.getNumChildren() == 3 );
       assertTrue( ( "child4" != r.getName() ) == false );
       r = null;
       r = p.removeChild(2);
       assertTrue( p.getNumChildren() == 2 );
       assertTrue( ( "child3" != r.getName() ) == false );
       r = null;
       r = p.removeChild(1);
       assertTrue( p.getNumChildren() == 1 );
       assertTrue( ( "child2" != r.getName() ) == false );
       r = null;
       r = p.removeChild(0);
       assertTrue( p.getNumChildren() == 0 );
       assertTrue( ( "child1" != r.getName() ) == false );
       r = null;
       p.addChild(c1);
       p.addChild(c2);
       p.addChild(c3);
       p.addChild(c4);
       p.addChild(c5);
       r = p.removeChild(0);
       assertTrue( p.getNumChildren() == 4 );
       assertTrue( ( "child1" != r.getName() ) == false );
       r = null;
       r = p.removeChild(0);
       assertTrue( p.getNumChildren() == 3 );
       assertTrue( ( "child2" != r.getName() ) == false );
       r = null;
       r = p.removeChild(0);
       assertTrue( p.getNumChildren() == 2 );
       assertTrue( ( "child3" != r.getName() ) == false );
       r = null;
       r = p.removeChild(0);
       assertTrue( p.getNumChildren() == 1 );
       assertTrue( ( "child4" != r.getName() ) == false );
       r = null;
       r = p.removeChild(0);
       assertTrue( p.getNumChildren() == 0 );
       assertTrue( ( "child5" != r.getName() ) == false );
       r = null;
       p.addChild(c1);
       p.addChild(c2);
       p.addChild(c3);
       p.addChild(c4);
       p.addChild(c5);
       r = p.removeChild(0);
       assertTrue( ( "child1" != r.getName() ) == false );
       p.insertChild(0,r);
       assertTrue( p.getNumChildren() == 5 );
       assertTrue( ( "child1" != p.getChild(0).getName() ) == false );
       r = null;
       r = p.removeChild(1);
       assertTrue( ( "child2" != r.getName() ) == false );
       p.insertChild(1,r);
       assertTrue( p.getNumChildren() == 5 );
       assertTrue( ( "child2" != p.getChild(1).getName() ) == false );
       r = null;
       r = p.removeChild(2);
       assertTrue( ( "child3" != r.getName() ) == false );
       p.insertChild(2,r);
       assertTrue( p.getNumChildren() == 5 );
       assertTrue( ( "child3" != p.getChild(2).getName() ) == false );
       r = null;
       r = p.removeChild(3);
       assertTrue( ( "child4" != r.getName() ) == false );
       p.insertChild(3,r);
       assertTrue( p.getNumChildren() == 5 );
       assertTrue( ( "child4" != p.getChild(3).getName() ) == false );
       r = null;
       r = p.removeChild(4);
       assertTrue( ( "child5" != r.getName() ) == false );
       p.insertChild(4,r);
       assertTrue( p.getNumChildren() == 5 );
       assertTrue( ( "child5" != p.getChild(4).getName() ) == false );
       r = null;
       p = null;
       c1 = null;
       c2 = null;
       c3 = null;
       c4 = null;
       c5 = null;
       attr = null;
       trp_p = null;
       trp_c1 = null;
       trp_c2 = null;
       trp_c3 = null;
       trp_c4 = null;
       trp_c5 = null;
 }
 public void test_Constraint_copyConstructor()
 {
     Constraint o1 = new Constraint(2,4);
       o1.setMetaId("c");
       assertTrue( o1.getMetaId() ==  "c" );
       XMLNode text = XMLNode.convertStringToXMLNode(" Some text ");
       XMLTriple triple = new XMLTriple("p", "http://www.w3.org/1999/xhtml", "");
       XMLAttributes att = new XMLAttributes();
       XMLNamespaces xmlns = new XMLNamespaces();
       xmlns.add("http://www.w3.org/1999/xhtml");
       XMLNode p = new XMLNode(triple,att,xmlns);
       p.addChild(text);
       XMLTriple triple1 = new XMLTriple("message", "", "");
       XMLAttributes att1 = new XMLAttributes();
       XMLNode message = new XMLNode(triple1,att1);
       message.addChild(p);
       ASTNode math = new ASTNode(libsbml.AST_CONSTANT_PI);
       o1.setMath(math);
       o1.setMessage(message);
       math = null;
       message = null;
       XMLNode msg;
       assertTrue( o1.getMath() != null );
       msg = o1.getMessage();
       assertTrue( msg != null );
       Constraint o2 = new Constraint(o1);
       assertTrue( o2.getMetaId() ==  "c" );
       assertTrue( o2.getMath() != null );
       msg = o2.getMessage();
       assertTrue( msg != null );
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }
    public static int Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine("  usage: addingEvidenceCodes_2 <input-filename> <output-filename>");
            Console.WriteLine("  Adds controlled vocabulary term to a species");
            Console.WriteLine();
            return 2;
        }

        SBMLDocument d = libsbml.readSBML(args[0]);
        long errors = d.getNumErrors();

        if (errors > 0)
        {
            Console.WriteLine("Read Error(s):");
            d.printErrors();

            Console.WriteLine("Correct the above and re-run.");
        }
        else
        {
            long n = d.getModel().getNumSpecies();

            if (n <= 0)
            {
                Console.WriteLine("Model has no species.\n Cannot add CV terms\n");
            }
            else
            {
                Species s = d.getModel().getSpecies(0);

                /* check that the species has a metaid
           * no CVTerms will be added if there is no metaid to reference
           */
                if (!s.isSetMetaId())
                    s.setMetaId("metaid_0000052");

                CVTerm cv1 = new CVTerm(libsbml.BIOLOGICAL_QUALIFIER);
                cv1.setBiologicalQualifierType(libsbml.BQB_OCCURS_IN);
                cv1.addResource("urn:miriam:obo.go:GO%3A0005764");

                s.addCVTerm(cv1);

                // now create the additional annotation

                //<rdf:Statement>
                //  <rdf:subject rdf:resource="#metaid_0000052"/>
                //  <rdf:predicate rdf:resource="http://biomodels.net/biology-qualifiers/occursIn"/>
                //  <rdf:object rdf:resource="urn:miriam:obo.go:GO%3A0005764"/>
                //  <bqbiol:isDescribedBy>
                //    <rdf:Bag>
                //      <rdf:li rdf:resource="urn:miriam:obo.eco:ECO%3A0000004"/>
                //      <rdf:li rdf:resource="urn:miriam:pubmed:7017716"/>
                //    </rdf:Bag>
                //  </bqbiol:isDescribedBy>
                //</rdf:Statement>

                /* attributes */
                XMLAttributes blank_att = new XMLAttributes();

                XMLAttributes resource_att = new XMLAttributes();

                /* create the outer statement node */
                XMLTriple statement_triple = new XMLTriple("Statement",
                                                       "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                       "rdf");

                XMLToken statement_token = new XMLToken(statement_triple, blank_att);

                XMLNode statement = new XMLNode(statement_token);

                /*create the subject node */
                XMLTriple subject_triple = new XMLTriple("subject",
                                                     "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                     "rdf");

                resource_att.clear();
                resource_att.add("rdf:resource", "#" + s.getMetaId());

                XMLToken subject_token = new XMLToken(subject_triple, resource_att);

                XMLNode subject = new XMLNode(subject_token);

                /*create the predicate node */
                XMLTriple predicate_triple = new XMLTriple("predicate",
                                                       "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                       "rdf");

                resource_att.clear();
                resource_att.add("rdf:resource",
                                 "http://biomodels.net/biology-qualifiers/occursIn");

                XMLToken predicate_token = new XMLToken(predicate_triple, resource_att);

                XMLNode predicate = new XMLNode(predicate_token);

                /*create the object node */
                XMLTriple object_triple = new XMLTriple("object",
                                                    "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                    "rdf");

                resource_att.clear();
                resource_att.add("rdf:resource", "urn:miriam:obo.go:GO%3A0005764");

                XMLToken object_token = new XMLToken(object_triple, resource_att);

                XMLNode object_ = new XMLNode(object_token);

                /* create the bqbiol node */
                XMLTriple bqbiol_triple = new XMLTriple("isDescribedBy",
                                                    "http://biomodels.net/biology-qualifiers/",
                                                    "bqbiol");

                XMLToken bqbiol_token = new XMLToken(bqbiol_triple, blank_att);

                XMLNode bqbiol = new XMLNode(bqbiol_token);

                /* create the bag node */
                XMLTriple bag_triple = new XMLTriple("Bag",
                                                 "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                 "rdf");

                XMLToken bag_token = new XMLToken(bag_triple, blank_att);

                XMLNode bag = new XMLNode(bag_token);

                /* create each li node and add to the bag */
                XMLTriple li_triple = new XMLTriple("li",
                                                "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                "rdf");

                resource_att.clear();
                resource_att.add("rdf:resource", "urn:miriam:obo.eco:ECO%3A0000004");

                XMLToken li_token = new XMLToken(li_triple, resource_att);
                li_token.setEnd();

                XMLNode li = new XMLNode(li_token);

                bag.addChild(li);

                resource_att.clear();
                resource_att.add("rdf:resource", "urn:miriam:pubmed:7017716");
                li_token = new XMLToken(li_triple, resource_att);
                li_token.setEnd();
                li = new XMLNode(li_token);

                bag.addChild(li);

                /* add the bag to bqbiol */
                bqbiol.addChild(bag);

                /* add subject, predicate, object and bqbiol to statement */
                statement.addChild(subject);
                statement.addChild(predicate);
                statement.addChild(object_);
                statement.addChild(bqbiol);

                /* create a top-level RDF element
           * this will ensure correct merging
           */

                XMLNamespaces xmlns = new XMLNamespaces();
                xmlns.add("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf");
                xmlns.add("http://purl.org/dc/elements/1.1/", "dc");
                xmlns.add("http://purl.org/dc/terms/", "dcterms");
                xmlns.add("http://www.w3.org/2001/vcard-rdf/3.0#", "vCard");
                xmlns.add("http://biomodels.net/biology-qualifiers/", "bqbiol");
                xmlns.add("http://biomodels.net/model-qualifiers/", "bqmodel");

                XMLTriple RDF_triple = new XMLTriple("RDF",
                                                 "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                 "rdf");

                XMLToken RDF_token = new XMLToken(RDF_triple, blank_att, xmlns);

                XMLNode annotation = new XMLNode(RDF_token);

                /* add the staement node to the RDF node */
                annotation.addChild(statement);

                s.appendAnnotation(annotation);

                libsbml.writeSBML(d, args[1]);
            }
        }

        return (int)errors;
    }
 public void test_Constraint_setMessage2()
 {
     XMLNode text = XMLNode.convertStringToXMLNode(" Some text ",null);
       XMLTriple triple = new  XMLTriple("p", "http://www.w3.org/1999/xhtml", "");
       XMLAttributes att = new  XMLAttributes();
       XMLNamespaces xmlns = new  XMLNamespaces();
       xmlns.add( "http://www.w3.org/1999/xhtml", "");
       XMLNode p = new XMLNode(triple,att,xmlns);
       p.addChild(text);
       XMLTriple triple1 = new  XMLTriple("message", "", "");
       XMLAttributes att1 = new  XMLAttributes();
       XMLNode node = new XMLNode(triple1,att1);
       node.addChild(p);
       int i = C.setMessage(node);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( C.isSetMessage() == true );
       i = C.unsetMessage();
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertEquals( false, C.isSetMessage() );
       if (C.getMessage() != null);
       {
       }
       node = null;
 }
    /**
     *
     * Creates an SBML model represented in "7.2 Example involving units"
     * in the SBML Level 2 Version 4 Specification.
     *
     */
    private static SBMLDocument createExampleInvolvingUnits()
    {
        int level = Level;
        int version = Version;

        //---------------------------------------------------------------------------
        //
        // Creates an SBMLDocument object
        //
        //---------------------------------------------------------------------------

        SBMLDocument sbmlDoc = new SBMLDocument(level, version);

        // Adds the namespace for XHTML to the SBMLDocument object.  We need this
        // because we will add notes to the model.  (By default, the SBML document
        // created by SBMLDocument only declares the SBML XML namespace.)

        sbmlDoc.getNamespaces().add("http://www.w3.org/1999/xhtml", "xhtml");

        //---------------------------------------------------------------------------
        //
        // Creates a Model object inside the SBMLDocument object.
        //
        //---------------------------------------------------------------------------

        Model model = sbmlDoc.createModel();
        model.setId("unitsExample");

        //---------------------------------------------------------------------------
        //
        // Creates UnitDefinition objects inside the Model object.
        //
        //---------------------------------------------------------------------------

        // Temporary pointers (reused more than once below).

        UnitDefinition unitdef;
        Unit unit;

        //---------------------------------------------------------------------------
        // (UnitDefinition1) Creates an UnitDefinition object ("substance").
        //
        // This has the effect of redefining the default unit of subtance for the
        // whole model.
        //---------------------------------------------------------------------------

        unitdef = model.createUnitDefinition();
        unitdef.setId("substance");

        //  Creates an Unit inside the UnitDefinition object

        unit = unitdef.createUnit();
        unit.setKind(libsbml.UNIT_KIND_MOLE);
        unit.setScale(-3);

        //--------------------------------------------------------------------------------
        // (UnitDefinition2) Creates an UnitDefinition object ("mmls")
        //--------------------------------------------------------------------------------

        // Note that we can reuse the pointers 'unitdef' and 'unit' because the
        // actual UnitDefinition object (along with the Unit objects within it)
        // is already attached to the Model object.

        unitdef = model.createUnitDefinition();
        unitdef.setId("mmls");

        //  Creates an Unit inside the UnitDefinition object ("mmls")

        unit = unitdef.createUnit();
        unit.setKind(libsbml.UNIT_KIND_MOLE);
        unit.setScale(-3);

        //  Creates an Unit inside the UnitDefinition object ("mmls")

        unit = unitdef.createUnit();
        unit.setKind(libsbml.UNIT_KIND_LITRE);
        unit.setExponent(-1);

        //  Creates an Unit inside the UnitDefinition object ("mmls")

        unit = unitdef.createUnit();
        unit.setKind(libsbml.UNIT_KIND_SECOND);
        unit.setExponent(-1);

        //--------------------------------------------------------------------------------
        // (UnitDefinition3) Creates an UnitDefinition object ("mml")
        //--------------------------------------------------------------------------------

        unitdef = model.createUnitDefinition();
        unitdef.setId("mml");

        //  Creates an Unit inside the UnitDefinition object ("mml")

        unit = unitdef.createUnit();
        unit.setKind(libsbml.UNIT_KIND_MOLE);
        unit.setScale(-3);

        //  Creates an Unit inside the UnitDefinition object ("mml")

        unit = unitdef.createUnit();
        unit.setKind(libsbml.UNIT_KIND_LITRE);
        unit.setExponent(-1);

        //---------------------------------------------------------------------------
        //
        // Creates a Compartment object inside the Model object.
        //
        //---------------------------------------------------------------------------

        Compartment comp;
        string compName = "cell";

        // Creates a Compartment object ("cell")

        comp = model.createCompartment();
        comp.setId(compName);

        // Sets the "size" attribute of the Compartment object.
        //
        //   The units of this Compartment object is the default SBML
        //   units of volume (litre), and thus we don't have to explicitly invoke
        //   setUnits("litre") function to set the default units.
        //
        comp.setSize(1);

        //---------------------------------------------------------------------------
        //
        // Creates Species objects inside the Model object.
        //
        //---------------------------------------------------------------------------

        // Temporary pointer (reused more than once below).

        Species sp;

        //---------------------------------------------------------------------------
        // (Species1) Creates a Species object ("x0")
        //---------------------------------------------------------------------------

        sp = model.createSpecies();
        sp.setId("x0");

        // Sets the "compartment" attribute of the Species object to identify the
        // compartnet in which the Species object located.

        sp.setCompartment(compName);

        // Sets the "initialConcentration" attribute of the Species object.
        //
        //  The units of this Species object is determined by two attributes of this
        //  Species object ("substanceUnits" and "hasOnlySubstanceUnits") and the
        //  "spatialDimensions" attribute of the Compartment object ("cytosol") in which
        //  this species object is located.
        //  Since the default values are used for "substanceUnits" (substance (mole))
        //  and "hasOnlySubstanceUnits" (false) and the value of "spatialDimension" (3)
        //  is greater than 0, the units of this Species object is  moles/liters .
        //
        sp.setInitialConcentration(1);

        //---------------------------------------------------------------------------
        // (Species2) Creates a Species object ("x1")
        //---------------------------------------------------------------------------

        sp = model.createSpecies();
        sp.setId("x1");
        sp.setCompartment(compName);
        sp.setInitialConcentration(1);

        //---------------------------------------------------------------------------
        // (Species3) Creates a Species object ("s1")
        //---------------------------------------------------------------------------

        sp = model.createSpecies();
        sp.setCompartment(compName);
        sp.setId("s1");
        sp.setInitialConcentration(1);

        //---------------------------------------------------------------------------
        // (Species4) Creates a Species object ("s2")
        //---------------------------------------------------------------------------

        sp = model.createSpecies();
        sp.setCompartment(compName);
        sp.setId("s2");
        sp.setInitialConcentration(1);

        //---------------------------------------------------------------------------
        //
        // Creates global Parameter objects inside the Model object.
        //
        //---------------------------------------------------------------------------

        Parameter para;

        // Creates a Parameter ("vm")

        para = model.createParameter();
        para.setId("vm");
        para.setValue(2);
        para.setUnits("mmls");

        // Creates a Parameter ("km")

        para = model.createParameter();
        para.setId("km");
        para.setValue(2);
        para.setUnits("mml");

        //---------------------------------------------------------------------------
        //
        // Creates Reaction objects inside the Model object.
        //
        //---------------------------------------------------------------------------

        // Temporary pointers.

        Reaction reaction;
        SpeciesReference spr;
        KineticLaw kl;

        //---------------------------------------------------------------------------
        // (Reaction1) Creates a Reaction object ("v1").
        //---------------------------------------------------------------------------

        reaction = model.createReaction();
        reaction.setId("v1");

        //---------------------------------------------------------------------------
        // Creates Reactant objects inside the Reaction object ("v1").
        //---------------------------------------------------------------------------

        // (Reactant1) Creates a Reactant object that references Species "x0"
        // in the model.

        spr = reaction.createReactant();
        spr.setSpecies("x0");

        //---------------------------------------------------------------------------
        // Creates a Product object inside the Reaction object ("v1").
        //---------------------------------------------------------------------------

        // Creates a Product object that references Species "s1" in the model.

        spr = reaction.createProduct();
        spr.setSpecies("s1");

        //---------------------------------------------------------------------------
        // Creates a KineticLaw object inside the Reaction object ("v1").
        //---------------------------------------------------------------------------

        kl = reaction.createKineticLaw();

        // Creates a <notes> element in the KineticLaw object.
        // Here we illustrate how to do it using a literal string.  This requires
        // known the required syntax of XHTML and the requirements for SBML <notes>
        // elements.  Later below, we show how to create notes using objects instead
        // of strings.

        string notesString = "<xhtml:p> ((vm * s1)/(km + s1)) * cell </xhtml:p>";
        kl.setNotes(notesString);

        //---------------------------------------------------------------------------
        // Creates an ASTNode object which represents the following KineticLaw object.
        //
        //  <math xmlns=\"http://www.w3.org/1998/Math/MathML\">
        //   <apply>
        //     <times/>
        //     <apply>
        //       <divide/>
        //       <apply>
        //         <times/>
        //           <ci> vm </ci>
        //           <ci> s1 </ci>
        //       </apply>
        //       <apply>
        //         <plus/>
        //           <ci> km </ci>
        //           <ci> s1 </ci>
        //       </apply>
        //     </apply>
        //     <ci> cell </ci>
        //    </apply>
        //  </math>
        //---------------------------------------------------------------------------

        //
        // In the following code, ASTNode objects, which construct an ASTNode tree
        // of the above math, are created and added in the order of preorder traversal
        // of the tree (i.e. the order corresponds to the nested structure of the above
        // MathML elements), and thus the following code maybe a bit more efficient but
        // maybe a bit difficult to read.
        //

        ASTNode astMath = new ASTNode(libsbml.AST_TIMES);

        astMath.addChild(new ASTNode(libsbml.AST_DIVIDE));
        ASTNode astDivide = astMath.getLeftChild();

        astDivide.addChild(new ASTNode(libsbml.AST_TIMES));
        ASTNode astTimes = astDivide.getLeftChild();

        astTimes.addChild(new ASTNode(libsbml.AST_NAME));
        astTimes.getLeftChild().setName("vm");

        astTimes.addChild(new ASTNode(libsbml.AST_NAME));
        astTimes.getRightChild().setName("s1");

        astDivide.addChild(new ASTNode(libsbml.AST_PLUS));
        ASTNode astPlus = astDivide.getRightChild();

        astPlus.addChild(new ASTNode(libsbml.AST_NAME));
        astPlus.getLeftChild().setName("km");

        astPlus.addChild(new ASTNode(libsbml.AST_NAME));
        astPlus.getRightChild().setName("s1");

        astMath.addChild(new ASTNode(libsbml.AST_NAME));
        astMath.getRightChild().setName("cell");

        //---------------------------------------------
        //
        // set the Math element
        //
        //------------------------------------------------

        kl.setMath(astMath);

        //---------------------------------------------------------------------------
        // (Reaction2) Creates a Reaction object ("v2").
        //---------------------------------------------------------------------------

        reaction = model.createReaction();
        reaction.setId("v2");

        //---------------------------------------------------------------------------
        // Creates Reactant objects inside the Reaction object ("v2").
        //---------------------------------------------------------------------------

        // (Reactant2) Creates a Reactant object that references Species "s1"
        // in the model.

        spr = reaction.createReactant();
        spr.setSpecies("s1");

        //---------------------------------------------------------------------------
        // Creates a Product object inside the Reaction object ("v2").
        //---------------------------------------------------------------------------

        // Creates a Product object that references Species "s2" in the model.

        spr = reaction.createProduct();
        spr.setSpecies("s2");

        //---------------------------------------------------------------------------
        // Creates a KineticLaw object inside the Reaction object ("v2").
        //---------------------------------------------------------------------------

        kl = reaction.createKineticLaw();

        // Sets a notes (by XMLNode) to the KineticLaw object.
        //
        // The following code is an alternative to using setNotes(const string&).
        // The equivalent code would be like this:
        //
        //     notesString = "<xhtml:p>((vm * s2)/(km + s2))*cell</xhtml:p>";
        //     kl.setNotes(notesString);

        // Creates an XMLNode of start element (<xhtml:p>) without attributes.

        XMLNode notesXMLNode = new XMLNode(
            new XMLTriple("p", "", "xhtml"),
            new XMLAttributes());

        // Adds a text element to the start element.

        notesXMLNode.addChild(new XMLNode(" ((vm * s2)/(km + s2)) * cell "));

        // Adds it to the kineticLaw object.

        kl.setNotes(notesXMLNode);

        //---------------------------------------------------------------------------
        // Sets a math (ASTNode object) to the KineticLaw object.
        //---------------------------------------------------------------------------

        // To create mathematical expressions, one would typically construct
        // an ASTNode tree as the above example code which creates a math of another
        // KineticLaw object.  Here, to save some space and illustrate another approach
        // of doing it, we will write out the formula in MathML form and then use a
        // libSBML convenience function to create the ASTNode tree for us.
        // (This is a bit dangerous; it's very easy to make mistakes when writing MathML
        // by hand, so in a real program, we would not really want to do it this way.)

        string mathXMLString = "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
        + "  <apply>"
        + "    <times/>"
        + "    <apply>"
        + "      <divide/>"
        + "      <apply>"
        + "        <times/>"
        + "        <ci> vm </ci>"
        + "        <ci> s2 </ci>"
        + "      </apply>"
        + "      <apply>"
        + "        <plus/>"
        + "          <ci> km </ci>"
        + "          <ci> s2 </ci>"
        + "      </apply>"
        + "    </apply>"
        + "    <ci> cell </ci>"
        + "  </apply>"
        + "</math>";

        astMath = libsbml.readMathMLFromString(mathXMLString);
        kl.setMath(astMath);

        //---------------------------------------------------------------------------
        // (Reaction3) Creates a Reaction object ("v3").
        //---------------------------------------------------------------------------

        reaction = model.createReaction();
        reaction.setId("v3");

        //---------------------------------------------------------------------------
        // Creates Reactant objects inside the Reaction object ("v3").
        //---------------------------------------------------------------------------

        // (Reactant2) Creates a Reactant object that references Species "s2"
        // in the model.

        spr = reaction.createReactant();
        spr.setSpecies("s2");

        //---------------------------------------------------------------------------
        // Creates a Product object inside the Reaction object ("v3").
        //---------------------------------------------------------------------------

        // Creates a Product object that references Species "x1" in the model.

        spr = reaction.createProduct();
        spr.setSpecies("x1");

        //---------------------------------------------------------------------------
        // Creates a KineticLaw object inside the Reaction object ("v3").
        //---------------------------------------------------------------------------

        kl = reaction.createKineticLaw();

        // Sets a notes (by string) to the KineticLaw object.

        notesString = "<xhtml:p> ((vm * x1)/(km + x1)) * cell </xhtml:p>";
        kl.setNotes(notesString);

        //---------------------------------------------------------------------------
        // Sets a math (ASTNode object) to the KineticLaw object.
        //---------------------------------------------------------------------------

        mathXMLString = "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
        + "  <apply>"
        + "    <times/>"
        + "    <apply>"
        + "      <divide/>"
        + "      <apply>"
        + "        <times/>"
        + "        <ci> vm </ci>"
        + "        <ci> x1 </ci>"
        + "      </apply>"
        + "      <apply>"
        + "        <plus/>"
        + "          <ci> km </ci>"
        + "          <ci> x1 </ci>"
        + "      </apply>"
        + "    </apply>"
        + "    <ci> cell </ci>"
        + "  </apply>"
        + "</math>";

        astMath = libsbml.readMathMLFromString(mathXMLString);
        kl.setMath(astMath);

        // Returns the created SBMLDocument object.
        // The returned object must be explicitly deleted by the caller,
        // otherwise memory leak will happen.

        return sbmlDoc;
    }
 public void test_XMLNode_create()
 {
     XMLNode node = new XMLNode();
       assertTrue( node != null );
       assertTrue( node.getNumChildren() == 0 );
       node = null;
       node = new XMLNode();
       assertTrue( node != null );
       XMLNode node2 = new XMLNode();
       assertTrue( node2 != null );
       node.addChild(node2);
       assertTrue( node.getNumChildren() == 1 );
       XMLNode node3 = new XMLNode();
       assertTrue( node3 != null );
       node.addChild(node3);
       assertTrue( node.getNumChildren() == 2 );
       node = null;
       node2 = null;
       node3 = null;
 }