public void setUp() { NS = new XMLNamespaces(); if (NS == null); { } }
public void test_SpeciesReference_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(2,1); sbmlns.addNamespaces(xmlns); SpeciesReference object1 = new SpeciesReference(sbmlns); assertTrue( object1.getTypeCode() == libsbml.SBML_SPECIES_REFERENCE ); assertTrue( object1.getMetaId() == "" ); assertTrue( object1.getNotes() == null ); assertTrue( object1.getAnnotation() == null ); assertTrue( object1.getLevel() == 2 ); assertTrue( object1.getVersion() == 1 ); assertTrue( object1.getNamespaces() != null ); assertTrue( object1.getNamespaces().getLength() == 2 ); object1 = null; }
public void test_Parameter_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(2,1); sbmlns.addNamespaces(xmlns); Parameter object1 = new Parameter(sbmlns); assertTrue( object1.getTypeCode() == libsbml.SBML_PARAMETER ); assertTrue( object1.getMetaId() == "" ); assertTrue( object1.getNotes() == null ); assertTrue( object1.getAnnotation() == null ); assertTrue( object1.getLevel() == 2 ); assertTrue( object1.getVersion() == 1 ); assertTrue( object1.getNamespaces() != null ); assertTrue( object1.getNamespaces().getLength() == 2 ); object1 = null; }
public void test_EventAssignment_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(2,1); sbmlns.addNamespaces(xmlns); EventAssignment object1 = new EventAssignment(sbmlns); assertTrue( object1.getTypeCode() == libsbml.SBML_EVENT_ASSIGNMENT ); assertTrue( object1.getMetaId() == "" ); assertTrue( object1.getNotes() == null ); assertTrue( object1.getAnnotation() == null ); assertTrue( object1.getLevel() == 2 ); assertTrue( object1.getVersion() == 1 ); assertTrue( object1.getNamespaces() != null ); assertTrue( object1.getNamespaces().getLength() == 2 ); object1 = null; }
public void test_StoichiometryMath_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(2,1); sbmlns.addNamespaces(xmlns); StoichiometryMath object1 = new StoichiometryMath(sbmlns); assertTrue( object1.getTypeCode() == libsbml.SBML_STOICHIOMETRY_MATH ); assertTrue( object1.getMetaId() == "" ); assertTrue( object1.getNotes() == null ); assertTrue( object1.getAnnotation() == null ); assertTrue( object1.getLevel() == 2 ); assertTrue( object1.getVersion() == 1 ); assertTrue( object1.getNamespaces() != null ); assertTrue( object1.getNamespaces().getLength() == 2 ); object1 = null; }
public void test_RateRule_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(2,1); sbmlns.addNamespaces(xmlns); Rule object1 = new RateRule(sbmlns); assertTrue( object1.getTypeCode() == libsbml.SBML_RATE_RULE ); assertTrue( object1.getMetaId() == "" ); assertTrue( object1.getNotes() == null ); assertTrue( object1.getAnnotation() == null ); assertTrue( object1.getLevel() == 2 ); assertTrue( object1.getVersion() == 1 ); assertTrue( object1.getNamespaces() != null ); assertTrue( object1.getNamespaces().getLength() == 2 ); object1 = null; }
public void test_CompartmentType_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(2,2); sbmlns.addNamespaces(xmlns); CompartmentType object1 = new CompartmentType(sbmlns); assertTrue( object1.getTypeCode() == libsbml.SBML_COMPARTMENT_TYPE ); assertTrue( object1.getMetaId() == "" ); assertTrue( object1.getNotes() == null ); assertTrue( object1.getAnnotation() == null ); assertTrue( object1.getLevel() == 2 ); assertTrue( object1.getVersion() == 2 ); assertTrue( object1.getNamespaces() != null ); assertTrue( object1.getNamespaces().getLength() == 2 ); object1 = null; }
public void test_SyntaxChecker_validXHTML() { 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); assertTrue( SyntaxChecker.hasExpectedXHTMLSyntax(node,null) == false ); triple = new XMLTriple("html", "", ""); ns.clear(); token = new XMLToken(triple,att,ns); node = new XMLNode(token); node.addChild(n1); assertTrue( SyntaxChecker.hasExpectedXHTMLSyntax(node,null) == false ); }
public void test_L3_Event_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(3,1); sbmlns.addNamespaces(xmlns); Event e = new Event(sbmlns); assertTrue( e.getTypeCode() == libsbml.SBML_EVENT ); assertTrue( e.getMetaId() == "" ); assertTrue( e.getNotes() == null ); assertTrue( e.getAnnotation() == null ); assertTrue( e.getLevel() == 3 ); assertTrue( e.getVersion() == 1 ); assertTrue( e.getNamespaces() != null ); assertTrue( e.getNamespaces().getLength() == 2 ); assertTrue( e.getId() == "" ); assertTrue( e.getName() == "" ); assertTrue( e.getUseValuesFromTriggerTime() == true ); assertEquals( false, e.isSetId() ); assertEquals( false, e.isSetName() ); assertEquals( false, e.isSetUseValuesFromTriggerTime() ); e = null; }
XMLNode(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces) : this(libsbmlPINVOKE.new_XMLNode__SWIG_4(XMLTriple.getCPtr(triple), XMLAttributes.getCPtr(attributes), XMLNamespaces.getCPtr(namespaces)), true) { if (libsbmlPINVOKE.SWIGPendingException.Pending) { throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); } }
/** * Adds the package's Level 2 namespace(s). * * @ifnot clike @internal @endif * * * * This method is related to special facilities designed to support * legacy behaviors surrounding SBML Level 2 models. Due to the * historical background of the SBML %Layout package, libSBML implements * special behavior for that package: it @em always creates a %Layout * plugin object for any SBML Level 2 document it reads in, * regardless of whether that document actually uses %Layout constructs. * Since Level 2 does not use namespaces on the top level of the * SBML document object, libSBML simply keys off the fact that the model * is a Level 2 model. To allow the extensions for the %Layout and * %Render (and possibly other) packages to support this behavior, the * SBMLExtension class contains special methods to allow packages to * hook themselves into the Level 2 parsing apparatus when necessary. * * @if clike * This virtual method should be overridden by all package extensions * that want to serialize to an SBML Level 2 annotation. In * Level 2, the XML namespace declaration for the package is not * placed on the top-level SBML document object but rather inside * individual annotations. addL2Namespaces() is invoked automatically * for Level 2 documents when an SBMLExtensionNamespace object is * created; removeL2Namespaces() is automatically invoked by * SBMLDocument to prevent the namespace(s) from being put on the * top-level SBML Level 2 element (because Level 2 doesn't * support namespaces there); and enableL2NamespaceForDocument() is * called automatically when any SBML document (of any Level/Version) is * read in. * @endif * * @param xmlns an XMLNamespaces object that will be used for the annotation. * Implementation should override this method with something that adds * the package's namespace(s) to the set of namespaces in @p xmlns. For * instance, here is the code from the %Layout package extension: * @code{.cpp} if (!xmlns->containsUri( LayoutExtension::getXmlnsL2())) xmlns->add(LayoutExtension::getXmlnsL2(), 'layout'); @endcode */ public new void addL2Namespaces(XMLNamespaces xmlns) { libsbmlPINVOKE.SBMLExtension_addL2Namespaces(swigCPtr, XMLNamespaces.getCPtr(xmlns)); }
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); S.setNotes(node); assertTrue( S.isSetNotes() == true ); token1 = new XMLToken(triple,att,ns); node1 = new XMLNode(token1); node1.addChild(node5); S.appendNotes(node1); 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_L3_Species_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(3,1); sbmlns.addNamespaces(xmlns); Species s = new Species(sbmlns); assertTrue( s.getTypeCode() == libsbml.SBML_SPECIES ); assertTrue( s.getMetaId() == "" ); assertTrue( s.getNotes() == null ); assertTrue( s.getAnnotation() == null ); assertTrue( s.getLevel() == 3 ); assertTrue( s.getVersion() == 1 ); assertTrue( s.getNamespaces() != null ); assertTrue( s.getNamespaces().getLength() == 2 ); assertTrue( s.getId() == "" ); assertTrue( s.getName() == "" ); assertTrue( s.getCompartment() == "" ); assertEquals( true, isnan(s.getInitialAmount()) ); assertEquals( true, isnan(s.getInitialConcentration()) ); assertTrue( s.getSubstanceUnits() == "" ); assertTrue( s.getHasOnlySubstanceUnits() == false ); assertTrue( s.getBoundaryCondition() == false ); assertTrue( s.getConstant() == false ); assertTrue( s.getConversionFactor() == "" ); assertEquals( false, s.isSetId() ); assertEquals( false, s.isSetName() ); assertEquals( false, s.isSetCompartment() ); assertEquals( false, s.isSetInitialAmount() ); assertEquals( false, s.isSetInitialConcentration() ); assertEquals( false, s.isSetSubstanceUnits() ); assertEquals( false, s.isSetHasOnlySubstanceUnits() ); assertEquals( false, s.isSetBoundaryCondition() ); assertEquals( false, s.isSetConstant() ); assertEquals( false, s.isSetConversionFactor() ); s = null; }
/** * Copy constructor; creates a copy of this XMLNamespaces list. * * @param orig the XMLNamespaces object to copy */ public XMLNamespaces(XMLNamespaces orig) : this(libsbmlPINVOKE.new_XMLNamespaces__SWIG_1(XMLNamespaces.getCPtr(orig)), true) { if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); }
void addL2Namespaces(XMLNamespaces xmlns) { libsbmlPINVOKE.SBMLExtension_addL2Namespaces(swigCPtr, XMLNamespaces.getCPtr(xmlns)); }
/** * Sets the namespaces relevant of this SBML object. * * The content of @p xmlns is copied, and this object's existing * namespace content is deleted. * * The SBMLNamespaces object encapsulates SBML Level/Version/namespaces * information. It is used to communicate the SBML Level, Version, and * (in Level 3) packages used in addition to SBML Level 3 Core. * * @param xmlns the namespaces to set * * * @return integer value indicating success/failure of the * function. @if clike The value is drawn from the * enumeration #OperationReturnValues_t. @endif The possible values * returned by this function are: * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink */ public int setNamespaces(XMLNamespaces xmlns) { int ret = libsbmlPINVOKE.SBase_setNamespaces(swigCPtr, XMLNamespaces.getCPtr(xmlns)); return ret; }
public void test_XMLToken_newSetters_setNamespaces2() { XMLTriple triple = new XMLTriple("test","",""); XMLToken token = new XMLToken(triple); XMLNamespaces ns = new XMLNamespaces(); assertTrue( token.getNamespacesLength() == 0 ); assertTrue( token.isNamespacesEmpty() == true ); ns.add( "http://test1.org/", "test1"); int i = token.setNamespaces(ns); assertTrue( i == libsbml.LIBSBML_INVALID_XML_OPERATION ); assertTrue( token.getNamespacesLength() == 0 ); assertTrue( token.isNamespacesEmpty() == true ); triple = null; token = null; ns = null; }
static XMLNode convertStringToXMLNode(string xmlstr, XMLNamespaces xmlns) { IntPtr cPtr = libsbmlPINVOKE.XMLNode_convertStringToXMLNode__SWIG_0(xmlstr, XMLNamespaces.getCPtr(xmlns)); XMLNode ret = (cPtr == IntPtr.Zero) ? null : new XMLNode(cPtr, true); return(ret); }
internal static HandleRef getCPtr(XMLNamespaces obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
int addPkgNamespaces(XMLNamespaces xmlns) { int ret = libsbmlPINVOKE.SBMLNamespaces_addPkgNamespaces(swigCPtr, XMLNamespaces.getCPtr(xmlns)); return(ret); }
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()) ); }
/** * Creates a new start element XMLNode with the given set of attributes and * namespace declarations. * * @param triple XMLTriple. * @param attributes XMLAttributes, the attributes to set. * @param namespaces XMLNamespaces, the namespaces to set. * @param line a long integer, the line number (default = 0). * @param column a long integer, the column number (default = 0). * * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif */ public XMLNode(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, long line, long column) : this(libsbmlPINVOKE.new_XMLNode__SWIG_2(XMLTriple.getCPtr(triple), XMLAttributes.getCPtr(attributes), XMLNamespaces.getCPtr(namespaces), line, column), true) { if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); }
internal static HandleRef getCPtrAndDisown(XMLNamespaces obj) { HandleRef ptr = new HandleRef(null, IntPtr.Zero); if (obj != null) { ptr = obj.swigCPtr; obj.swigCMemOwn = false; } return ptr; }
/** * Returns an XMLNode which is derived from a string containing XML * content. * * The XML namespace must be defined using argument @p xmlns if the * corresponding XML namespace attribute is not part of the string of the * first argument. * * @param xmlstr string to be converted to a XML node. * @param xmlns XMLNamespaces the namespaces to set (default value is @c null). * * @note The caller owns the returned XMLNode and is reponsible for * deleting it. The returned XMLNode object is a dummy root (container) * XMLNode if the top-level element in the given XML string is NOT * <code><html></code>, <code><body></code>, * <code><annotation></code>, or <code><notes></code>. In * the dummy root node, each top-level element in the given XML string is * contained as a child XMLNode. XMLToken::isEOF() can be used to * identify if the returned XMLNode object is a dummy node. * * @return a XMLNode which is converted from string @p xmlstr. If the * conversion failed, this method returns @c null. * * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif */ public static XMLNode convertStringToXMLNode(string xmlstr, XMLNamespaces xmlns) { IntPtr cPtr = libsbmlPINVOKE.XMLNode_convertStringToXMLNode__SWIG_0(xmlstr, XMLNamespaces.getCPtr(xmlns)); XMLNode ret = (cPtr == IntPtr.Zero) ? null : new XMLNode(cPtr, true); return ret; }
public void test_FunctionDefinition_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(2,1); sbmlns.addNamespaces(xmlns); FunctionDefinition object1 = new FunctionDefinition(sbmlns); assertTrue( object1.getTypeCode() == libsbml.SBML_FUNCTION_DEFINITION ); assertTrue( object1.getMetaId() == "" ); assertTrue( object1.getNotes() == null ); assertTrue( object1.getAnnotation() == null ); assertTrue( object1.getLevel() == 2 ); assertTrue( object1.getVersion() == 1 ); assertTrue( object1.getNamespaces() != null ); assertTrue( object1.getNamespaces().getLength() == 2 ); object1 = null; }
public void test_L3_Unit_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(3,1); sbmlns.addNamespaces(xmlns); Unit u = new Unit(sbmlns); assertTrue( u.getTypeCode() == libsbml.SBML_UNIT ); assertTrue( u.getMetaId() == "" ); assertTrue( u.getNotes() == null ); assertTrue( u.getAnnotation() == null ); assertTrue( u.getLevel() == 3 ); assertTrue( u.getVersion() == 1 ); assertTrue( u.getNamespaces() != null ); assertTrue( u.getNamespaces().getLength() == 2 ); assertTrue( u.getKind() == libsbml.UNIT_KIND_INVALID ); assertEquals( true, isnan(u.getExponentAsDouble()) ); assertEquals( true, isnan(u.getMultiplier()) ); assertEquals( false, u.isSetKind() ); assertEquals( false, u.isSetExponent() ); assertEquals( false, u.isSetMultiplier() ); assertEquals( false, u.isSetScale() ); u = null; }
public void test_NS_copyConstructor() { XMLNamespaces ns = new XMLNamespaces(); ns.add("http://test1.org/", "test1"); assertTrue( ns.getLength() == 1 ); assertTrue( ns.isEmpty() == false ); assertTrue( ns.getPrefix(0) == "test1" ); assertTrue( ns.getURI("test1") == "http://test1.org/" ); XMLNamespaces ns2 = new XMLNamespaces(ns); assertTrue( ns2.getLength() == 1 ); assertTrue( ns2.isEmpty() == false ); assertTrue( ns2.getPrefix(0) == "test1" ); assertTrue( ns2.getURI("test1") == "http://test1.org/" ); ns2 = null; ns = null; }
/** * Returns the XML namespaces declared for this token. * * @return the XML namespace declarations for this XML element. */ public XMLNamespaces getNamespaces() { XMLNamespaces ret = new XMLNamespaces(libsbmlPINVOKE.XMLToken_getNamespaces(swigCPtr), false); return ret; }
/** * Add the XML namespaces of package extensions in the given XMLNamespace * object to the set of namespaces within this SBMLNamespaces object. * * Non-package XML namespaces are not added by this function. * * @param xmlns the XML namespaces to be added. * * @return integer value indicating success/failure of the * function. @if clike The value is drawn from the * enumeration #OperationReturnValues_t. @endif The possible values * returned by this function are: * @li @link libsbmlcs#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink * @li @link libsbmlcs#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE@endlink * * @note XML namespaces of a non-registered package extensions are not * added (just ignored) by this function. @link libsbmlcs#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE@endlink will be returned if the given * xmlns is null. */ /* libsbml-internal */ public int addPkgNamespaces(XMLNamespaces xmlns) { int ret = libsbmlPINVOKE.SBMLNamespaces_addPkgNamespaces(swigCPtr, XMLNamespaces.getCPtr(xmlns)); return ret; }
/** * Creates an XML start element with attributes and namespace declarations. * * @param triple an XMLTriple object describing the start tag. * * @param attributes XMLAttributes, the attributes to set on the element to * be created. * * @param namespaces XMLNamespaces, the namespaces to set on the element to * be created. * * @param line a long integer, the line number to associate with the * token (default = 0). * * @param column a long integer, the column number to associate with the * token (default = 0). * * @ifnot hasDefaultArgs @htmlinclude warn-default-args-in-docs.html @endif */ public XMLToken(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces) : this(libsbmlPINVOKE.new_XMLToken__SWIG_3(XMLTriple.getCPtr(triple), XMLAttributes.getCPtr(attributes), XMLNamespaces.getCPtr(namespaces)), true) { if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); }
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); S.setNotes(body_node); S.appendNotes(p_node1); 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; }
/** * Sets the XML namespaces on this XML element. * * * * This operation only makes sense for XML start elements. This * method will return @link libsbml#LIBSBML_INVALID_XML_OPERATION LIBSBML_INVALID_XML_OPERATION@endlink if this XMLToken object is not an XML start * element. * * * * @param namespaces the XMLNamespaces object to be assigned to this XMLToken object. * * * @return integer value indicating success/failure of the * function. @if clike The value is drawn from the * enumeration #OperationReturnValues_t. @endif The possible values * returned by this function are: * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink * @li @link libsbml#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink * @li @link libsbml#LIBSBML_INVALID_XML_OPERATION LIBSBML_INVALID_XML_OPERATION@endlink * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink * * @note This function replaces any existing XMLNamespaces object on this * XMLToken object with the new one given by @p namespaces. */ public int setNamespaces(XMLNamespaces namespaces) { int ret = libsbmlPINVOKE.XMLToken_setNamespaces(swigCPtr, XMLNamespaces.getCPtr(namespaces)); if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); return ret; }
/** * Removes SBML Level 2 namespaces from the namespace list. * * @if clike * This will call all overridden * <code>SBMLExtension::removeL2Namespaces()</code> methods. * @endif * * @param xmlns an XMLNamespaces object listing one or more namespaces * to be removed. */ public void removeL2Namespaces(XMLNamespaces xmlns) { libsbmlPINVOKE.SBMLExtensionRegistry_removeL2Namespaces(swigCPtr, XMLNamespaces.getCPtr(xmlns)); }
public void test_L3_Compartment_createWithNS() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "testsbml"); SBMLNamespaces sbmlns = new SBMLNamespaces(3,1); sbmlns.addNamespaces(xmlns); Compartment c = new Compartment(sbmlns); assertTrue( c.getTypeCode() == libsbml.SBML_COMPARTMENT ); assertTrue( c.getMetaId() == "" ); assertTrue( c.getNotes() == null ); assertTrue( c.getAnnotation() == null ); assertTrue( c.getLevel() == 3 ); assertTrue( c.getVersion() == 1 ); assertTrue( c.getNamespaces() != null ); assertTrue( c.getNamespaces().getLength() == 2 ); assertTrue( c.getId() == "" ); assertTrue( c.getName() == "" ); assertTrue( c.getUnits() == "" ); assertTrue( c.getOutside() == "" ); assertEquals( true, isnan(c.getSpatialDimensionsAsDouble()) ); assertEquals( true, isnan(c.getVolume()) ); assertTrue( c.getConstant() == true ); assertEquals( false, c.isSetId() ); assertEquals( false, c.isSetSpatialDimensions() ); assertEquals( false, c.isSetName() ); assertEquals( false, c.isSetSize() ); assertEquals( false, c.isSetVolume() ); assertEquals( false, c.isSetUnits() ); assertEquals( false, c.isSetOutside() ); assertEquals( false, c.isSetConstant() ); c = null; }