/* * Reads other XML such as math/notes etc. */ bool Uncertainty::readOtherXML(XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "UncertML") { const XMLToken& token = stream.next(); stream.skipText(); delete mUncertML; XMLNode* xml = new XMLNode(stream); mUncertML = new UncertMLNode(xml); stream.skipPastEnd(token); delete xml; read = true; } if (SBase::readOtherXML(stream)) { read = true; } return read; }
bool ArraysASTPlugin::readMatrixRow(XMLInputStream& stream, const std::string& reqd_prefix, const XMLToken& currentElement) { bool read = false; stream.skipText(); const XMLToken nextElement = stream.peek(); const string& nextName = nextElement.getName(); unsigned int numChildren = determineNumChildren(stream, "matrixrow"); mVector = new ASTArraysVectorFunctionNode(AST_LINEAR_ALGEBRA_MATRIXROW_CONSTRUCTOR); mVector->setExpectedNumChildren(numChildren); // read attributes on this element here since we have already consumed // the element ExpectedAttributes expectedAttributes; mVector->addExpectedAttributes(expectedAttributes, stream); read = mVector->ASTBase::readAttributes(currentElement.getAttributes(), expectedAttributes, stream, currentElement); if (read == false) { mVector = NULL; } else { read = mVector->read(stream, reqd_prefix); } return read; }
/** * Sets the type of an ASTNode based on the given MathML <ci> element. * Errors will be logged in the stream's SBMLErrorLog object. */ static void setTypeCI (ASTNode& node, const XMLToken& element, XMLInputStream& stream) { if (element.getName() == "csymbol") { string url; element.getAttributes().readInto("definitionURL", url); if ( url == URL_DELAY ) node.setType(AST_FUNCTION_DELAY); else if ( url == URL_TIME ) node.setType(AST_NAME_TIME); else if ( url == URL_AVOGADRO ) node.setType(AST_NAME_AVOGADRO); else { static_cast <SBMLErrorLog*> (stream.getErrorLog())->logError(BadCsymbolDefinitionURLValue, stream.getSBMLNamespaces()->getLevel(), stream.getSBMLNamespaces()->getVersion()); } } else if (element.getName() == "ci") { node.setDefinitionURL(element.getAttributes()); } const string name = trim( stream.next().getCharacters() ); node.setName( name.c_str() ); }
bool ASTCiNumberNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; const XMLToken element = stream.next (); const string& nameE = element.getName(); ASTBase::checkPrefix(stream, reqd_prefix, element); if (nameE != "ci") { #if 0 cout << "HELP\n"; #endif return read; } ExpectedAttributes expectedAttributes; addExpectedAttributes(expectedAttributes, stream); read = readAttributes(element.getAttributes(), expectedAttributes, stream, element); const string name = trim( stream.next().getCharacters() ); setName((name)); ASTBase::setType(AST_NAME); if (read == true) stream.skipPastEnd(element); return read; }
bool ASTCnBase::read(XMLInputStream& stream, const std::string& ) { bool read = false; const XMLToken element = stream.next (); ExpectedAttributes expectedAttributes; addExpectedAttributes(expectedAttributes, stream); read = readAttributes(element.getAttributes(), expectedAttributes, stream, element); string prefix; if (isSetUnits() == true) { prefix = element.getAttrPrefix( element.getAttrIndex("units", stream.getSBMLNamespaces()->getURI())); setUnitsPrefix(prefix); } //return ASTBase::read(stream, reqd_prefix); return read; }
bool AnalyticVolume::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); if (stream.getSBMLNamespaces() == NULL) { stream.setSBMLNamespaces(new SBMLNamespaces(getLevel(), getVersion())); } delete mMath; mMath = readMathML(stream, prefix); read = true; } if (SBase::readOtherXML(stream)) { read = true; } return read; }
void ASTBase::logError (XMLInputStream& stream, const XMLToken& element, SBMLErrorCode_t code, const std::string& msg) { SBMLNamespaces* ns = stream.getSBMLNamespaces(); if (ns != NULL) { static_cast <SBMLErrorLog*> (stream.getErrorLog())->logError( code, ns->getLevel(), ns->getVersion(), msg, element.getLine(), element.getColumn()); } else { static_cast <SBMLErrorLog*> (stream.getErrorLog())->logError( code, SBML_DEFAULT_LEVEL, SBML_DEFAULT_VERSION, msg, element.getLine(), element.getColumn()); } }
/** * Sets the type of an ASTNode based on the given MathML <cn> element. * Errors will be logged in the stream's SBMLErrorLog object. */ static void setTypeCN (ASTNode& node, const XMLToken& element, XMLInputStream& stream) { string type = "real"; element.getAttributes().readInto("type", type); // here is the only place we might encounter the sbml:units attribute string units = ""; element.getAttributes().readInto("units", units); if (type == "real") { double value = 0; istringstream isreal; isreal.str( stream.next().getCharacters() ); isreal >> value; node.setValue(value); if (isreal.fail() || node.isInfinity() || node.isNegInfinity() ) { static_cast <SBMLErrorLog*> (stream.getErrorLog())->logError(FailedMathMLReadOfDouble, stream.getSBMLNamespaces()->getLevel(), stream.getSBMLNamespaces()->getVersion()); } }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, etc. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool InitialAssignment::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { // if this is level 1 there shouldnt be any math!!! if (getLevel() == 1) { logError(NotSchemaConformant, getLevel(), getVersion(), "SBML Level 1 does not support MathML."); delete mMath; return false; } if (mMath != NULL) { if (getLevel() < 3) { logError(NotSchemaConformant, getLevel(), getVersion(), "Only one <math> element is permitted inside a " "particular containing element."); } else { logError(OneMathElementPerInitialAssign, getLevel(), getVersion(), "The <initialAssignment> with symbol '" + getSymbol() + "' contains more than one <math> element."); } } /* check for MathML namespace * this may be explicitly declared here * or implicitly declared on the whole document */ const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); delete mMath; mMath = readMathML(stream, prefix); if (mMath != NULL) mMath->setParentSBMLObject(this); read = true; } /* ------------------------------ * * (EXTENSION) * * ------------------------------ */ if ( SBase::readOtherXML(stream) ) read = true; return read; }
void ASTCnBase::addExpectedAttributes(ExpectedAttributes& attributes, XMLInputStream& stream) { ASTBase::addExpectedAttributes(attributes, stream); if (stream.getSBMLNamespaces() != NULL && stream.getSBMLNamespaces()->getLevel() > 2) { attributes.add("units"); } attributes.add("type"); }
bool ASTArraysVectorFunctionNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; ASTBase * child = NULL; const XMLToken element = stream.peek (); ASTBase::checkPrefix(stream, reqd_prefix, element); const char* name; unsigned int numChildrenAdded = 0; while (stream.isGood() && numChildrenAdded < getExpectedNumChildren())// && stream.peek().isEndFor(element) == false) { stream.skipText(); name = stream.peek().getName().c_str(); if (representsNumber(ASTBase::getTypeFromName(name)) == true) { child = new ASTNumber(); } else { child = new ASTFunction(); } read = child->read(stream, reqd_prefix); stream.skipText(); if (read == true && addChild(child) == LIBSBML_OPERATION_SUCCESS) { numChildrenAdded++; } else { read = false; break; } } if (getExpectedNumChildren() == 0 && numChildrenAdded == 0) { read = true; } return read; }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, PolygonObject. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool ParametricObject::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "PolygonObject") { delete mPolygonObject; mPolygonObject = PolygonObject::readPolygonObject(stream); if (mPolygonObject) mPolygonObject->setParentSBMLObject(this); read = true; } /* ------------------------------ * * (EXTENSION) * *------------------------------- */ if ( SBase::readOtherXML(stream) ) read = true; return read; }
bool ArraysASTPlugin::read(XMLInputStream& stream, const std::string& reqd_prefix, const XMLToken& currentElement) { bool read = false; stream.skipText(); const string& currentName = currentElement.getName(); //ASTBase::checkPrefix(stream, reqd_prefix, currentElement); // create appropriate sub class if (currentName == "vector") { read = readVector(stream, reqd_prefix, currentElement); } #if (0) else if (currentName == "matrix") { read = readMatrix(stream, reqd_prefix, currentElement); } else if (currentName == "matrixrow") { read = readMatrixRow(stream, reqd_prefix, currentElement); } #endif return read; }
bool ASTSemanticsNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; ASTBase * child = NULL; const XMLToken element = stream.peek (); ASTBase::checkPrefix(stream, reqd_prefix, element); const char* name;// = element.getName().c_str(); if (stream.isGood())// && stream.peek().isEndFor(element) == false) { stream.skipText(); name = stream.peek().getName().c_str(); if (representsNumber(ASTBase::getTypeFromName(name)) == true) { child = new ASTNumber(); } else { child = new ASTFunction(); } read = child->read(stream, reqd_prefix); stream.skipText(); if (read == false || addChild(child) != LIBSBML_OPERATION_SUCCESS) { delete child; child = NULL; read = false; } } unsigned int i = 0; while ( i < getNumAnnotations()) { if (stream.peek().getName() == "annotation" || stream.peek().getName() == "annotation-xml") { XMLNode semanticAnnotation = XMLNode(stream); addSemanticsAnnotation(semanticAnnotation.clone()); i++; } else { stream.next(); } } return true; }
bool ASTCnRealNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; const XMLToken element = stream.peek (); const string& name = element.getName(); ASTBase::checkPrefix(stream, reqd_prefix, element); if (name != "cn") { #if 0 cout << "HELP\n"; #endif return read; } ASTCnBase::read(stream, reqd_prefix); std::string type = "real"; element.getAttributes().readInto("type", type); if (type == "real") { double value = 0; istringstream isreal; isreal.str( stream.next().getCharacters() ); isreal >> value; setReal(value); ASTBase::setType(AST_REAL); if (isreal.fail() || (util_isInf(getValue()) > 0) || (util_isInf(getValue()) < 0) ) { logError(stream, element, FailedMathMLReadOfDouble); } read = true; }
bool ASTBase::read(XMLInputStream& stream, const std::string& ) { ExpectedAttributes expectedAttributes; addExpectedAttributes(expectedAttributes, stream); const XMLToken element = stream.next (); return readAttributes(element.getAttributes(), expectedAttributes, stream, element); }
LIBSBML_CPP_NAMESPACE_BEGIN static unsigned int determineNumChildren(XMLInputStream & stream, const std::string element = "") { unsigned int n = 0; n = stream.determineNumberChildren(element); return n; }
bool ASTCnIntegerNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; const XMLToken element = stream.peek (); const string& name = element.getName(); ASTBase::checkPrefix(stream, reqd_prefix, element); if (name != "cn") { cout << "HELP\n"; return read; } ASTCnBase::read(stream, reqd_prefix); std::string type; element.getAttributes().readInto("type", type); if (type == "integer") { int value = 0; istringstream isint; isint.str( stream.next().getCharacters() ); isint >> value; if (isint.fail()) { logError(stream, element, FailedMathMLReadOfInteger); } else if ( sizeof(int) > 4 && ( (value > SBML_INT_MAX) || (value < SBML_INT_MIN) ) ) { logError(stream, element, FailedMathMLReadOfInteger); } setInteger(value); ASTBase::setType(AST_INTEGER); read = true; }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, etc. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool StoichiometryMath::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { // if this is level 1 there shouldnt be any math!!! if (getLevel() == 1) { logError(NotSchemaConformant, getLevel(), getVersion(), "SBML Level 1 does not support MathML."); delete mMath; return false; } /* check for MathML namespace * this may be explicitly declared here * or implicitly declared on the whole document */ const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); delete mMath; mMath = readMathML(stream, prefix); if (mMath) mMath->setParentSBMLObject(this); read = true; } /* ------------------------------ * * (EXTENSION) * * ------------------------------ */ if ( SBase::readOtherXML(stream) ) read = true; return read; }
/* * Creates a new XMLNode by reading XMLTokens from stream. The stream must * be positioned on a start element (stream.peek().isStart() == true) and * will be read until the matching end element is found. */ XMLNode::XMLNode (XMLInputStream& stream) : XMLToken( stream.next() ) { if ( isEnd() ) return; std::string s; while ( stream.isGood() ) { const XMLToken& next = stream.peek(); if ( next.isStart() ) { addChild( XMLNode(stream) ); } else if ( next.isText() ) { s = trim(next.getCharacters()); if (s != "") addChild( stream.next() ); else stream.skipText(); } else if ( next.isEnd() ) { stream.next(); break; } } }
bool SedSetValue::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); delete mMath; mMath = readMathML(stream, prefix); read = true; } if (SedBase::readOtherXML(stream)) { read = true; } return read; }
bool ASTCnExponentialNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; const XMLToken element = stream.peek (); const string& name = element.getName(); ASTBase::checkPrefix(stream, reqd_prefix, element); if (name != "cn") { #if 0 cout << "HELP\n"; #endif return read; } ASTCnBase::read(stream, reqd_prefix); std::string type; element.getAttributes().readInto("type", type); if (type == "e-notation") { double mantissa = 0; long exponent = 0; istringstream ismantissa; istringstream isexponent; ismantissa.str( stream.next().getCharacters() ); ismantissa >> mantissa; if (stream.peek().getName() == "sep") { stream.next(); isexponent.str( stream.next().getCharacters() ); isexponent >> exponent; }
bool Uncertainty::readOtherXML(XMLInputStream& stream) { const string& name = stream.peek().getName(); if (name == "UncertML") { delete mUncertML; XMLNode * xml = new XMLNode(stream); mUncertML = new UncertMLNode(xml); delete xml; return true; } return false; }
void ASTCiNumberNode::addExpectedAttributes(ExpectedAttributes& attributes, XMLInputStream& stream) { ASTBase::addExpectedAttributes(attributes, stream); SBMLNamespaces * sbmlns = stream.getSBMLNamespaces(); if (sbmlns != NULL) { if (sbmlns->getLevel() > 2) { attributes.add("definitionURL"); } else if (sbmlns->getLevel() == 2 && sbmlns->getVersion() == 5) { attributes.add("definitionURL"); } } }
bool ASTBase::readAttributes(const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes, XMLInputStream& stream, const XMLToken& element) { bool read = true; // // check that all attributes are expected // for (int i = 0; i < attributes.getLength(); i++) { std::string name = attributes.getName(i); std::string uri = attributes.getURI(i); std::string prefix = attributes.getPrefix(i); // // To allow prefixed attribute whose namespace doesn't belong to // core or extension package. // // (e.g. xsi:type attribute in Curve element in layout extension) // if (!prefix.empty()) { if ( expectedAttributes.hasAttribute(prefix + ":" + name) ) continue; } if (!expectedAttributes.hasAttribute(name)) { std::string message = "The attribute '" + name + "' is not permitted" + " on a <" + element.getName() + "> element."; if (name == "type") { logError(stream, element, DisallowedMathTypeAttributeUse, message); } else if (name == "encoding") { logError(stream, element, DisallowedMathMLEncodingUse, message); } else if (name == "definitionURL") { logError(stream, element, DisallowedDefinitionURLUse, message); } else if (name == "units") { if (stream.getSBMLNamespaces() != NULL && stream.getSBMLNamespaces()->getLevel() > 2) { logError(stream, element, DisallowedMathUnitsUse, message); } else { message = "The 'units' attribute was introduced in SBML Level 3."; logError(stream, element, InvalidMathMLAttribute, message); } } else { logError(stream, element, InvalidMathElement, message); } // not sufficient to make the read bad //return false; } } string id; string className; string style; attributes.readInto( "id" , id ); attributes.readInto( "class" , className ); attributes.readInto( "style" , style ); if (!id.empty()) { if (setId(id) != LIBSBML_OPERATION_SUCCESS) { read = false; } } if (!className.empty()) { if (setClass(className) != LIBSBML_OPERATION_SUCCESS) { read = false; } } if (!style.empty()) { if (setStyle(style) != LIBSBML_OPERATION_SUCCESS) { read = false; } } unsigned int i = 0; while (read == true && i < getNumPlugins()) { read = getPlugin(i)->readAttributes(attributes, expectedAttributes, stream, element, getExtendedType()); i++; } return read; }
/** @cond doxygenLibsbmlInternal */ bool FbcModelPlugin::readOtherXML (SBase* parentObject, XMLInputStream& stream) { #ifndef ANNOATION return false; #else bool readAnnotationFromStream = false; const string& name = stream.peek().getName(); if (!(name.empty()) && name != "annotation") { return readAnnotationFromStream; } try { XMLNode *pAnnotation = parentObject->getAnnotation(); FBC_CREATE_NS_WITH_VERSION(fbcns, getSBMLNamespaces(), getPackageVersion()); if (!pAnnotation) { // // (NOTES) // // annotation element has not been parsed by the parent element // (Model) of this plugin object, thus annotation element is // parsed via the given XMLInputStream object in this block. // const string& name = stream.peek().getName(); if (name == "annotation") { pAnnotation = new XMLNode(stream); parseFbcAnnotation(pAnnotation, mAssociations, fbcns); if (mAssociations.size() > 0) { // // Removes the annotation for layout extension from the annotation // of parent element (pAnnotation) and then set the new annotation // (newAnnotation) to the parent element. // XMLNode *newAnnotation = deleteFbcAnnotation(pAnnotation); parentObject->setAnnotation(newAnnotation); delete newAnnotation; } else { // // No layout annotation is included in the read annotation // (pAnnotation) and thus just set the annotation to the parent // element. // parentObject->setAnnotation(pAnnotation); } delete pAnnotation; readAnnotationFromStream = true; } } else if (mAssociations.size() == 0) { // // (NOTES) // // annotation element has been parsed by the parent element // (Model) of this plugin object, thus the annotation element // set to the above pAnnotation variable is parsed in this block. // parseFbcAnnotation(pAnnotation, mAssociations, fbcns); if (mAssociations.size() > 0) { // // Removes the annotation for layout extension from the annotation // of parent element (pAnnotation) and then set the new annotation // (newAnnotation) to the parent element. // XMLNode *newAnnotation = deleteFbcAnnotation(pAnnotation); parentObject->setAnnotation(newAnnotation); } readAnnotationFromStream = true; } delete fbcns; } catch(...) { // an exception occured, most likely becase a namespace constructor // threw an exception, catching this here, and return false, to indicate // that the annotation wasn't read. readAnnotationFromStream = false; } return readAnnotationFromStream; #endif }
bool ASTCSymbolDelayNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; XMLToken element = stream.peek (); const string& nameE = element.getName(); if (nameE != "csymbol") { #if 0 cout << "HELP\n"; #endif return read; } ASTBase::read(stream, reqd_prefix); const string nameDelay = trim( stream.next().getCharacters() ); setName((nameDelay)); ASTBase::setType(AST_FUNCTION_DELAY); stream.skipPastEnd(element); const char * name; ASTBase * child = NULL; unsigned int numChildrenAdded = 0; // catch if we do not have two children if (getExpectedNumChildren() > 0) { while (stream.isGood() && numChildrenAdded < getExpectedNumChildren()) { stream.skipText(); name = stream.peek().getName().c_str(); if (representsNumber(ASTBase::getTypeFromName(name)) == true) { child = new ASTNumber(); } else { child = new ASTFunction(); } read = child->read(stream, reqd_prefix); stream.skipText(); if (read == true && addChild(child) == LIBSBML_OPERATION_SUCCESS) { numChildrenAdded++; } else { read = false; break; } } } else { stream.skipPastEnd(element); read = true; } return read; }
bool ASTNaryFunctionNode::read(XMLInputStream& stream, const std::string& reqd_prefix) { bool read = false; ASTBase * child = NULL; const XMLToken element = stream.peek (); ASTBase::checkPrefix(stream, reqd_prefix, element); const char* name = element.getName().c_str(); int type = getTypeFromName(name); setType(type); ASTBase::read(stream, reqd_prefix); unsigned int numChildrenAdded = 0; if (getExpectedNumChildren() > 0) { while (stream.isGood() && numChildrenAdded < getExpectedNumChildren()) { stream.skipText(); name = stream.peek().getName().c_str(); if (representsNumber(ASTBase::getTypeFromName(name)) == true) { child = new ASTNumber(); } else { child = new ASTFunction(); } read = child->read(stream, reqd_prefix); stream.skipText(); if (read == true && addChild(child) == LIBSBML_OPERATION_SUCCESS) { numChildrenAdded++; } else { delete child; child = NULL; read = false; break; } } } else { stream.skipPastEnd(element); read = true; } if (read == true && type == AST_FUNCTION_ROOT && getExpectedNumChildren() == 1 && ASTFunctionBase::getChild(0)->getType() != AST_QUALIFIER_DEGREE) { /* HACK TO REPLICATE OLD BEHAVIOUR */ /* we need to add the qualifier child for the degree 2 */ ASTFunction * degree = new ASTFunction(AST_QUALIFIER_DEGREE); ASTNumber * int2 = new ASTNumber(AST_INTEGER); int2->setInteger(2); degree->addChild(int2->deepCopy()); this->prependChild(degree->deepCopy()); delete int2; delete degree; } //if (read == false) //{ // stream.skipPastEnd(element); //} return read; }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, etc. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool Rule::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { // if this is level 1 there shouldnt be any math!!! if (getLevel() == 1) { logError(NotSchemaConformant, getLevel(), getVersion(), "SBML Level 1 does not support MathML."); delete mMath; return false; } if (mMath != NULL) { if (getLevel() < 3) { logError(NotSchemaConformant, getLevel(), getVersion(), "Only one <math> element is permitted inside a " "particular containing element."); } else { std::string details; if (isAssignment() == true) { details = "The <assignmentRule> with variable '" + getVariable() +"'"; } else if (isRate() == true) { details = "The <rateRule> with variable '" + getVariable() +"'"; } else { details = "The <algebraicRule>"; } details += " contains more than one <math> element."; logError(OneMathElementPerRule, getLevel(), getVersion(), details); } } delete mMath; /* check for MathML namespace * this may be explicitly declared here * or implicitly declared on the whole document */ const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); mMath = readMathML(stream, prefix); if (mMath != NULL) mMath->setParentSBMLObject(this); read = true; } /* ------------------------------ * * (EXTENSION) * * ------------------------------ */ if ( SBase::readOtherXML(stream) ) read = true; return read; }
/* * Subclasses should override this method to read (and store) XHTML, * MathML, etc. directly from the XMLInputStream. * * @return true if the subclass read from the stream, false otherwise. */ bool Constraint::readOtherXML (XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { // if this is level 1 there shouldnt be any math!!! if (getLevel() == 1) { logError(NotSchemaConformant, getLevel(), getVersion(), "SBML Level 1 does not support MathML."); delete mMath; return false; } if (mMath) { if (getLevel() < 3) { logError(NotSchemaConformant, getLevel(), getVersion(), "Only one <math> element is permitted inside a " "particular containing element."); } else { logError(OneMathElementPerConstraint, getLevel(), getVersion(), "The <constraint> contains more than one <math> element."); } } // If there's a <message>, it's supposed to show up first if (mMessage && getLevel() == 2) logError(IncorrectOrderInConstraint); /* check for MathML namespace * this may be explicitly declared here * or implicitly declared on the whole document */ const XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); delete mMath; mMath = readMathML(stream, prefix); if (mMath) mMath->setParentSBMLObject(this); read = true; } else if (name == "message") { if (mMessage) { if (getLevel() < 3) { logError(NotSchemaConformant, getLevel(), getVersion(), "Only one <message> element is permitted inside a " "particular containing element."); } else { logError(OneMessageElementPerConstraint, getLevel(), getVersion()); } } delete mMessage; mMessage = new XMLNode(stream); // // checks if the given default namespace (if any) is a valid // SBML namespace // const XMLNamespaces &xmlns = mMessage->getNamespaces(); checkDefaultNamespace(&xmlns,"message"); if (getSBMLDocument() != NULL) { if (getSBMLDocument()->getNumErrors() == 0) { checkXHTML(mMessage); } } read = true; } /* ------------------------------ * * (EXTENSION) * * ------------------------------ */ if ( SBase::readOtherXML(stream) ) read = true; return read; }