/** @cond doxygenLibsbmlInternal */ void LayoutSBMLDocumentPlugin::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes&) { // for now don't read the required flag for L2 models if (getSBMLDocument() != NULL && getSBMLDocument()->getLevel() < 3) return; unsigned int numErrs = getErrorLog()->getNumErrors(); XMLTriple tripleRequired("required", mURI, getPrefix()); bool assigned = attributes.readInto(tripleRequired, mRequired); if (assigned == false) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("layout", LayoutAttributeRequiredMustBeBoolean, getPackageVersion(), getLevel(), getVersion()); } else { getErrorLog()->logPackageError("layout", LayoutAttributeRequiredMissing, getPackageVersion(), getLevel(), getVersion()); } } else { mIsSetRequired = true; /* LOG ERROR RELATING TO EXPECTED VALUE */ if (mRequired == true) { getErrorLog()->logPackageError("layout", LayoutRequiredFalse, getPackageVersion(), getLevel(), getVersion()); } } }
/* * Subclasses should override this method to read values from the given * XMLAttributes set into their specific fields. Be sure to call your * parents implementation of this method as well. */ void OntologyTerm::readAttributes (const XMLAttributes& attributes) { NMBase::readAttributes(attributes); const unsigned int level = getLevel (); const unsigned int version = getVersion(); std::vector<std::string> expectedAttributes; expectedAttributes.clear(); expectedAttributes.push_back("metaid"); expectedAttributes.push_back("id"); expectedAttributes.push_back("term"); expectedAttributes.push_back("sourceTermId"); expectedAttributes.push_back("ontologyURI"); // check that all attributes are expected for (int i = 0; i < attributes.getLength(); i++) { std::vector<std::string>::const_iterator end = expectedAttributes.end(); std::vector<std::string>::const_iterator begin = expectedAttributes.begin(); std::string name = attributes.getName(i); if (std::find(begin, end, name) == end) { logUnknownAttribute(name, level, version, "<ontologyTerm>"); } } const string id = "id"; bool assigned = attributes.readInto(id, mId, getErrorLog(), true); if (assigned && mId.size() == 0) { logEmptyString(id, level, version, "<ontologyTerm>"); } if (!SyntaxChecker::isValidSBMLSId(mId)) logError(NUMLInvalidIdSyntax); attributes.readInto("term", mTerm); attributes.readInto("sourceTermId", mSourceTermId); attributes.readInto("ontologyURI", mOntologyURI); }
void plotXMLVisitor::startElement (const char * name, const XMLAttributes &atts) { current_element = name; for (int i=0; i<atts.size();i++) { if (string(atts.getName(i)) == string("axis")) { if (string(atts.getValue(i)) == string("x")) axis = eX; else if (string(atts.getValue(i)) == string("y2")) axis = eY2; else axis = eY; } else { cerr << "Unknown attribute " << atts.getName(i) << " encountered." << endl; exit (-1); } if (i == 1) { cerr << "Too many attributes. Offending attribute (item:" << i << ") is " << atts.getName(i) << endl; exit (-1); } } if (!first_element_read) { if (current_element != string("plotset")) { cerr << endl << " This is not a valid plotset description (" << current_element << ")" << endl; exit (-1); } else { first_element_read = true; } } if (current_element == "page") { vPages.push_back(Page()); inPage = true; } else if (current_element == "plot") { if (!inPage) { vPlots.push_back(Plots()); } else { vPages.back().vPlots.push_back(Plots()); } } }
//----------------------------------------------------------------------------// void Imageset_xmlHandler::elementImageStart(const XMLAttributes& attributes) { if (!d_imageset) throw InvalidRequestException("Imageset_xmlHandler::elementImageStart: " "Attempt to access null object."); const String name(attributes.getValueAsString(ImageNameAttribute)); Rect rect; rect.d_left = static_cast<float>(attributes.getValueAsInteger(ImageXPosAttribute)); rect.d_top = static_cast<float>(attributes.getValueAsInteger(ImageYPosAttribute)); rect.setWidth( static_cast<float>(attributes.getValueAsInteger(ImageWidthAttribute))); rect.setHeight( static_cast<float>(attributes.getValueAsInteger(ImageHeightAttribute))); const Point offset( static_cast<float>(attributes.getValueAsInteger(ImageXOffsetAttribute, 0)), static_cast<float>(attributes.getValueAsInteger(ImageYOffsetAttribute, 0))); d_imageset->defineImage(name, rect, offset); }
void Tool::read(const XMLAttributes &attrs) { if (attrs.has("units")) try { setUnits(ToolUnits::parse(attrs["units"])); } CATCH_ERROR; if (attrs.has("shape")) try { setShape(ToolShape::parse(attrs["shape"])); } CATCH_ERROR; double scale = getUnits() == ToolUnits::UNITS_INCH ? 25.4 : 1; if (attrs.has("length")) setLength(String::parseDouble(attrs["length"]) * scale); else THROWS("Tool " << number << " missing length"); if (attrs.has("radius")) setRadius(String::parseDouble(attrs["radius"]) * scale); else if (attrs.has("diameter")) setRadius(String::parseDouble(attrs["diameter"]) / 2.0 * scale); else THROWS("Tool " << number << " has neither radius or diameter"); if (attrs.has("snub_diameter")) setSnubDiameter(String::parseDouble(attrs["snub_diameter"]) * scale); }
/* * Read values from the given XMLAttributes set into their specific fields. */ void Dimension::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfDimensions - which will have * happened immediately prior to this read */ if (getErrorLog() != NULL && static_cast<ListOfDimensions*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("arrays", ArraysUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("arrays", ArraysUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } SBase::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("arrays", ArraysUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("arrays", ArraysUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } bool assigned = false; // // id SId ( use = "optional" ) // assigned = attributes.readInto("id", mId); if (assigned == true) { // check string is not empty and correct syntax if (mId.empty() == true) { logEmptyString(mId, getLevel(), getVersion(), "<Dimension>"); } else if (SyntaxChecker::isValidSBMLSId(mId) == false && getErrorLog() != NULL) { getErrorLog()->logError(InvalidIdSyntax, getLevel(), getVersion(), "The syntax of the attribute id='" + mId + "' does not conform."); } } // // name string ( use = "optional" ) // assigned = attributes.readInto("name", mName); if (assigned == true) { // check string is not empty if (mName.empty() == true) { logEmptyString(mName, getLevel(), getVersion(), "<Dimension>"); } } // // size SIdRef ( use = "required" ) // assigned = attributes.readInto("size", mSize); if (assigned == true) { // check string is not empty and correct syntax if (mSize.empty() == true) { logEmptyString(mSize, getLevel(), getVersion(), "<Dimension>"); } else if (SyntaxChecker::isValidSBMLSId(mSize) == false && getErrorLog() != NULL) { getErrorLog()->logError(InvalidIdSyntax, getLevel(), getVersion(), "The syntax of the attribute size='" + mSize + "' does not conform."); } } else { std::string message = "Arrays attribute 'size' is missing."; getErrorLog()->logPackageError("arrays", ArraysUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message); } // // dim unsigned int ( use = "required" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetDim = attributes.readInto("dim", mDim); if (mIsSetDim == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("arrays", ArraysUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion); } else { std::string message = "Arrays attribute 'dim' is missing."; getErrorLog()->logPackageError("arrays", ArraysUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message); } } } }
/* * Read values from the given XMLAttributes set into their specific fields. */ void FbcModelPlugin::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; SBasePlugin::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("fbc", FbcUnknown, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("fbc", FbcUnknown, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } } } // // strict bool ( use = "required" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetStrict = attributes.readInto("strict", mStrict); if (mIsSetStrict == false && getPackageVersion() > 1) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("fbc", FbcModelStrictMustBeBoolean, getPackageVersion(), sbmlLevel, sbmlVersion, "", getLine(), getColumn()); } else { std::string message = "Fbc attribute 'strict' is missing from <Model> object."; getErrorLog()->logPackageError("fbc", FbcModelMustHaveStrict, getPackageVersion(), sbmlLevel, sbmlVersion, message, getLine(), getColumn()); } } } }
void TerrainData_xmlHandler::startElement(const String& element, const XMLAttributes& attrs) { if (element == "Terrain") { mData->mName = attrs.getValueAs<String>("name", Ogre::StringUtil::BLANK); mData->mXSize = attrs.getValueAs<uint>("xsize"); mData->mZSize = attrs.getValueAs<uint>("zsize"); mData->mTileSize = attrs.getValueAs<uint>("tileSize"); } else if (element == "scale") { mData->mScale = Ogre::Vector3(attrs.getValueAs<Real>("x"), attrs.getValueAs<Real>("y"), attrs.getValueAs<Real>("z")); if (mData->mScale.x <= 0 || mData->mScale.y <= 0 || mData->mScale.z <= 0) { OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Invalidate scale definition in terrain file", "TerrainData_xmlHandler::startElement"); } mData->mPosition = Ogre::Vector3(- mData->mScale.x * mData->mXSize / 2, 0, - mData->mScale.z * mData->mZSize / 2); } else if (element == "size") { mData->mScale = Ogre::Vector3(attrs.getValueAs<Real>("x") / mData->mXSize, attrs.getValueAs<Real>("y"), attrs.getValueAs<Real>("z") / mData->mZSize); if (mData->mScale.x <= 0 || mData->mScale.y <= 0 || mData->mScale.z <= 0) { OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Invalidate size definition in terrain file", "TerrainData_xmlHandler::startElement"); } mData->mPosition = Ogre::Vector3(- mData->mScale.x * mData->mXSize / 2, 0, - mData->mScale.z * mData->mZSize / 2); } else if (element == "position") { mData->mPosition = Ogre::Vector3(attrs.getValueAs<Real>("x"), attrs.getValueAs<Real>("y"), attrs.getValueAs<Real>("z")); } else if (element == "centre" || element == "center") { mData->mPosition = Ogre::Vector3(attrs.getValueAs<Real>("x") - mData->mScale.x * mData->mXSize / 2, attrs.getValueAs<Real>("y"), attrs.getValueAs<Real>("z") - mData->mScale.z * mData->mZSize / 2); } else if (element == "heightmap") { const String& type = attrs.getValueAs<String>("type", "standard"); const String& filename = attrs.getValue("filename"); if (type != "image" && type != "standard" && type != "raw") { OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Invalidate height data type", "TerrainData_xmlHandler::startElement"); } mData->mHeightmapType = type; mData->mHeightmapFilename = filename; if (mData->mHeightmapFilename.empty()) { OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Invalidate height data filename", "TerrainData_xmlHandler::startElement"); } } else if (element == "gridInfo") { const String& type = attrs.getValueAs<String>("type", "standard"); const String& filename = attrs.getValue("filename"); if (type != "standard") { OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Invalidate height info type", "TerrainData_xmlHandler::startElement"); } mData->mGridInfoFilename = filename; if (mData->mGridInfoFilename.empty()) { OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Invalidate grid info filename", "TerrainData_xmlHandler::startElement"); } } else if (element == "lightmap") { const String& type = attrs.getValueAs<String>("type", "standard"); const String& filename = attrs.getValue("filename"); if (type != "standard" && type != "image") { OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Invalidate lightmap type", "TerrainData_xmlHandler::startElement"); } mData->mLightmapType = type; mData->mLightmapFilename = filename; if (mData->mLightmapFilename.empty()) { OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Invalidate lightmap filename", "TerrainData_xmlHandler::startElement"); } } else if (element == "pixmap") { TerrainData::Pixmap pixmap; pixmap.textureId = attrs.getValueAs<uint>("textureId"); pixmap.left = attrs.getValueAs<Real>("left", 0); pixmap.top = attrs.getValueAs<Real>("top", 0); pixmap.right = attrs.getValueAs<Real>("right", 1); pixmap.bottom = attrs.getValueAs<Real>("bottom", 1); if (!(0 <= pixmap.left && pixmap.left <= 1 && 0 <= pixmap.top && pixmap.top <= 1 && 0 <= pixmap.right && pixmap.right <= 1 && 0 <= pixmap.bottom && pixmap.bottom <= 1)) { OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Invalidate pixmap definition in terrain file", "TerrainData_xmlHandler::startElement"); } mData->mPixmaps.push_back(pixmap); } else if (element == "texture") { const String& type = attrs.getValueAs<String>("type", "image"); const String& filename = attrs.getValue("filename"); if (type != "image") { OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Invalidate texture type", "TerrainData_xmlHandler::startElement"); } mData->mTextures.push_back(filename); } else if (element == "template") { const String& name = attrs.getValue("name"); const String& material = attrs.getValue("material"); std::pair<TerrainData::MaterialTemplates::iterator, bool> inserted = mData->mMaterialTemplates.insert(TerrainData::MaterialTemplates::value_type( name, material)); if (!inserted.second) { OGRE_EXCEPT(Ogre::Exception::ERR_DUPLICATE_ITEM, "Duplicate material template '" + inserted.first->first + "' in terrain file", "TerrainData_xmlHandler::startElement"); } } else if (element == "fog_replacement") { TerrainData::FogReplacement fogReplacement; fogReplacement.programNames[Ogre::FOG_NONE] = attrs.getValue("none"); fogReplacement.programNames[Ogre::FOG_EXP] = attrs.getValue("exp"); fogReplacement.programNames[Ogre::FOG_EXP2] = attrs.getValue("exp2"); fogReplacement.programNames[Ogre::FOG_LINEAR] = attrs.getValue("linear"); mData->mFogReplacements.push_back(fogReplacement); } else if (element == "ambient") { readColourRGB(attrs, mData->mSurfaceParams.ambient); } else if (element == "diffuse") { readColourRGB(attrs, mData->mSurfaceParams.diffuse); } else if (element == "specular") { readColourRGB(attrs, mData->mSurfaceParams.specular); mData->mSurfaceParams.shininess = attrs.getValueAs<Real>("shininess", mData->msDefaultSurfaceParams.shininess); } else if (element == "emissive") { readColourRGB(attrs, mData->mSurfaceParams.emissive); } else if (element == "pixmaps") { // no attributes } else if (element == "textures") { // no attributes } else if (element == "materials") { // no attributes } else if (element == "surface") { // no attributes } // anything else is an error which *should* have already been caught by XML validation else { OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, "Unexpected data was found while parsing the terrain file: '" + element + "' is unknown.", "TerrainData_xmlHandler::startElement"); } }
/* * Read values from the given XMLAttributes set into their specific fields. */ void AnalyticVolume::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfAnalyticVolumes - which will have * happened immediately prior to this read */ if (getErrorLog() != NULL && static_cast<ListOfAnalyticVolumes*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } } } SBase::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } } } bool assigned = false; // // id SId ( use = "required" ) // assigned = attributes.readInto("id", mId); if (assigned == true) { // check string is not empty and correct syntax if (mId.empty() == true) { logEmptyString(mId, getLevel(), getVersion(), "<AnalyticVolume>"); } else if (SyntaxChecker::isValidSBMLSId(mId) == false && getErrorLog() != NULL) { getErrorLog()->logError(InvalidIdSyntax, getLevel(), getVersion(), "The syntax of the attribute id='" + mId + "' does not conform.", getLine(), getColumn()); } } else { std::string message = "Spatial attribute 'id' is missing from 'analyticVolume' object."; getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message, getLine(), getColumn()); } // // functionType enum ( use = "required" ) // mFunctionType = FUNCTIONKIND_UNKNOWN; std::string stringValue; assigned = attributes.readInto("functionType", stringValue); if (assigned == true) { // parse enum mFunctionType = FunctionKind_parse(stringValue.c_str()); if(mFunctionType == FUNCTIONKIND_UNKNOWN) { std::string message = "Unknown value for spatial attribute 'functionType' in 'analyticVolume' object: " + stringValue; getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message, getLine(), getColumn()); } } if(mFunctionType == FUNCTIONKIND_UNKNOWN) { std::string message = "Spatial attribute 'functionType' is missing from 'analyticVolume' object."; getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message, getLine(), getColumn()); } // // ordinal int ( use = "required" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetOrdinal = attributes.readInto("ordinal", mOrdinal); if (mIsSetOrdinal == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, "", getLine(), getColumn()); } else { std::string message = "Spatial attribute 'ordinal' is missing from 'analyticVolume' object."; getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message); } } } // // domainType SIdRef ( use = "required" ) // assigned = attributes.readInto("domainType", mDomainType); if (assigned == true) { // check string is not empty and correct syntax if (mDomainType.empty() == true) { logEmptyString(mDomainType, getLevel(), getVersion(), "<AnalyticVolume>"); } else if (SyntaxChecker::isValidSBMLSId(mDomainType) == false && getErrorLog() != NULL) { getErrorLog()->logError(InvalidIdSyntax, getLevel(), getVersion(), "The syntax of the attribute domainType='" + mDomainType + "' does not conform."); } } else { std::string message = "Spatial attribute 'domainType' is missing from 'analyticVolume' object."; getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message, getLine(), getColumn()); } }
//----------------------------------------------------------------------------// void Config_xmlHandler::handleDefaultCursorElement(const XMLAttributes& attr) { d_defaultPointerImage = attr.getValueAsString(ImageAttribute, ""); }
//----------------------------------------------------------------------------// void Config_xmlHandler::handleXMLParserElement(const XMLAttributes& attr) { d_xmlParserName = attr.getValueAsString(NameAttribute, ""); }
/* * Reads the expected attributes into the member data variables */ void CoordinateComponent::readAttributes(const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { unsigned int level = getLevel(); unsigned int version = getVersion(); unsigned int pkgVersion = getPackageVersion(); unsigned int numErrs; bool assigned = false; SBMLErrorLog* log = getErrorLog(); if (static_cast<ListOfCoordinateComponents*>(getParentSBMLObject())->size() < 2) { numErrs = log->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (log->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = log->getError(n)->getMessage(); log->remove(UnknownPackageAttribute); log->logPackageError("spatial", SpatialGeometryLOCoordinateComponentsAllowedAttributes, pkgVersion, level, version, details); } else if (log->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = log->getError(n)->getMessage(); log->remove(UnknownCoreAttribute); log->logPackageError("spatial", SpatialGeometryLOCoordinateComponentsAllowedCoreAttributes, pkgVersion, level, version, details); } } } SBase::readAttributes(attributes, expectedAttributes); numErrs = log->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (log->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = log->getError(n)->getMessage(); log->remove(UnknownPackageAttribute); log->logPackageError("spatial", SpatialCoordinateComponentAllowedAttributes, pkgVersion, level, version, details); } else if (log->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = log->getError(n)->getMessage(); log->remove(UnknownCoreAttribute); log->logPackageError("spatial", SpatialCoordinateComponentAllowedCoreAttributes, pkgVersion, level, version, details); } } // // id SId (use = "required" ) // assigned = attributes.readInto("id", mId); if (assigned == true) { if (mId.empty() == true) { logEmptyString(mId, level, version, "<CoordinateComponent>"); } else if (SyntaxChecker::isValidSBMLSId(mId) == false) { logError(SpatialIdSyntaxRule, level, version, "The id '" + mId + "' does " "not conform to the syntax."); } } else { std::string message = "Spatial attribute 'id' is missing from the " "<CoordinateComponent> element."; log->logPackageError("spatial", SpatialCoordinateComponentAllowedAttributes, pkgVersion, level, version, message); } // // type enum (use = "required" ) // std::string type; assigned = attributes.readInto("type", type); if (assigned == true) { if (type.empty() == true) { logEmptyString(type, level, version, "<CoordinateComponent>"); } else { mType = CoordinateKind_fromString(type.c_str()); if (CoordinateKind_isValid(mType) == 0) { std::string msg = "The type on the <CoordinateComponent> "; if (isSetId()) { msg += "with id '" + getId() + "'"; } msg += "is '" + type + "', which is not a valid option."; log->logPackageError("spatial", SpatialCoordinateComponentTypeMustBeCoordinateKindEnum, pkgVersion, level, version, msg); } } } else { std::string message = "Spatial attribute 'type' is missing."; log->logPackageError("spatial", SpatialCoordinateComponentAllowedAttributes, pkgVersion, level, version, message); } // // unit UnitSIdRef (use = "optional" ) // assigned = attributes.readInto("unit", mUnit); if (assigned == true) { if (mUnit.empty() == true) { logEmptyString(mUnit, level, version, "<CoordinateComponent>"); } else if (SyntaxChecker::isValidSBMLSId(mUnit) == false) { logError(SpatialCoordinateComponentUnitMustBeUnitSId, level, version, "The attribute unit='" + mUnit + "' does not conform to the syntax."); } } }
/* * Read values from the given XMLAttributes set into their specific fields. */ void Objective::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); // look to see whether an unknown attribute error was logged // during the read of the listOfFluxBounds - which will have // happened immediately prior to this read if (getErrorLog() != NULL && static_cast<ListOfObjectives*>(getParentSBMLObject())->size() < 2) { unsigned int numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("fbc", FbcLOObjectivesAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("fbc", FbcLOObjectivesAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } SBase::readAttributes(attributes,expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { unsigned int numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("fbc", FbcObjectiveRequiredAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("fbc", FbcObjectiveAllowedL3Attributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } // // Reads an attribute "id" (optional) // bool assigned = attributes.readInto("id", mId); if (assigned) { // "id" attribute is set to this fbc element if (mId.empty()) { // // Logs an error if the "id" attribute is empty. // logEmptyString(mId, sbmlLevel, sbmlVersion, "<fbc>"); } else if (!SyntaxChecker::isValidSBMLSId(mId)) { // // Logs an error if the "id" attribute doesn't // conform to the SBML type SId. // getErrorLog()->logPackageError("fbc", FbcSBMLSIdSyntax, getPackageVersion(), sbmlLevel, sbmlVersion); } } else { std::string message = "Fbc attribute 'id' is missing."; getErrorLog()->logPackageError("fbc", FbcObjectiveRequiredAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, message); } attributes.readInto("name", mName); // // type string ( use = "required" ) // std::string type; assigned = attributes.readInto("type", type); if (assigned == true) { // check string is not empty if (type.empty() == true) { logEmptyString(type, sbmlLevel, sbmlVersion, "<Objective>"); } else { mType = ObjectiveType_fromString( type.c_str() ); if (ObjectiveType_isValidObjectiveType((ObjectiveType_t)(int)mType) == 0) { getErrorLog()->logPackageError("fbc", FbcObjectiveTypeMustBeEnum, getPackageVersion(), sbmlLevel, sbmlVersion); } } } else { std::string message = "Fbc attribute 'type' is missing."; getErrorLog()->logPackageError("fbc", FbcObjectiveRequiredAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, message); } }
/* * Read values from the given XMLAttributes set into their specific fields. */ void InteriorPoint::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfInteriorPoints - which will have * happened immediately prior to this read */ if (getErrorLog() != NULL && static_cast<ListOfInteriorPoints*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } SBase::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } bool assigned = false; // // coord1 double ( use = "required" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetCoord1 = attributes.readInto("coord1", mCoord1); if (mIsSetCoord1 == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion); } else { std::string message = "Spatial attribute 'coord1' is missing."; getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message); } } } // // coord2 double ( use = "optional" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetCoord2 = attributes.readInto("coord2", mCoord2); if (mIsSetCoord2 == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion); } } } // // coord3 double ( use = "optional" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetCoord3 = attributes.readInto("coord3", mCoord3); if (mIsSetCoord3 == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion); } } } }
/* * Subclasses should override this method to read values from the given * XMLAttributes set into their specific fields. Be sure to call your * parents implementation of this method as well. */ void Rule::readL1Attributes (const XMLAttributes& attributes) { const unsigned int level = getLevel (); const unsigned int version = getVersion(); // // formula: string { use="required" } (L1v1, L1v2) // attributes.readInto("formula", mFormula, getErrorLog(), true, getLine(), getColumn()); // // type { use="optional" default="scalar" } (L1v1, L1v2) // // This attribute is handled by ListOfRules::createObject(); // if ( isSpeciesConcentration() ) { // // specie : SName { use="required" } (L1v1) // species: SName { use="required" } (L1v2) // const string s = (level == 1 && version == 1) ? "specie" : "species"; bool assigned = attributes.readInto(s, mVariable, getErrorLog(), true, getLine(), getColumn()); if (assigned && mVariable.size() == 0) { logEmptyString(s, level, version, "<rule>"); } if (!SyntaxChecker::isValidInternalSId(mVariable)) logError(InvalidIdSyntax, getLevel(), getVersion(), "The syntax of the attribute " + s + "='" + mVariable + "' does not conform."); } else if ( isCompartmentVolume() ) { // // compartment: SName { use="required" } (L1v1, L1v2) // bool assigned = attributes.readInto("compartment", mVariable, getErrorLog(), true, getLine(), getColumn()); if (assigned && mVariable.size() == 0) { logEmptyString("compartment", level, version, "<rule>"); } if (!SyntaxChecker::isValidInternalSId(mVariable)) logError(InvalidIdSyntax, getLevel(), getVersion(), "The syntax of the attribute compartment='" + mVariable + "' does not conform."); } else if ( isParameter() ) { // // name: SName { use="required" } (L1v1, L1v2) // bool assigned = attributes.readInto("name", mVariable, getErrorLog(), true, getLine(), getColumn()); if (assigned && mVariable.size() == 0) { logEmptyString("name", level, version, "<rule>"); } if (!SyntaxChecker::isValidInternalSId(mVariable)) logError(InvalidIdSyntax, getLevel(), getVersion(), "The syntax of the attribute name='" + mVariable + "' does not conform."); // // units { use="optional" } (L1v1, L1v2); // attributes.readInto("units", mUnits, getErrorLog(), false, getLine(), getColumn()); } }
void UserSettingsParser::processScheme(SchemeLoaderState* pState, const XMLAttributes& atts) { LPCTSTR pName = atts.getValue(_T("name")); if(pName && ((int)_tcslen(pName) > 0)) { if(!m_loadingPreset) { CT2CA schemeName(pName); m_pCurScheme = new SchemeDetails(schemeName); } else { CT2CA schemeName(pName); SchemeDetailsMap::iterator iScheme = pState->m_SchemeDetails.find(std::string(schemeName)); if(iScheme != pState->m_SchemeDetails.end()) { m_pCurScheme = (*iScheme).second; } else { m_pCurScheme = NULL; } } if(m_pCurScheme == NULL) return; //pScheme = new CustomisedScheme; m_SchemeName = pName; pState->m_State = US_SCHEME; LPCTSTR temp = atts.getValue(_T("ovtabs")); if(temp != NULL && _tcslen(temp) > 0) { m_pCurScheme->CustomFlagFlags |= schOverrideTabs; if(SZTRUE(temp)) // Signal that we definitely want to override the tab use. m_pCurScheme->CustomFlags |= schOverrideTabs; temp = atts.getValue(_T("usetabs")); if(temp != NULL && _tcslen(temp) > 0) { m_pCurScheme->CustomFlagFlags |= schUseTabs; if(SZTRUE(temp)) m_pCurScheme->CustomFlags |= schUseTabs; } } temp = atts.getValue(_T("tabwidth")); if(temp != NULL && _tcslen(temp) > 0) { m_pCurScheme->CustomFlagFlags |= schOverrideTabSize; m_pCurScheme->CustomFlags |= schOverrideTabSize; m_pCurScheme->CustomTabWidth = _ttoi(temp); } } #ifdef _DEBUG else { LOG(_T("UserSettingsParser::processScheme(): Scheme section without name attribute.\n")); } #endif }
/* * Read values from the given XMLAttributes set into their specific fields. */ void SpeciesFeatureValue::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfSpeciesFeatureValues - which will have * happened immediately prior to this read */ if (getErrorLog() != NULL && static_cast<ListOfSpeciesFeatureValues*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("multi", MultiUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("multi", MultiUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } SBase::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("multi", MultiUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("multi", MultiUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } bool assigned = false; // // value SIdRef ( use = "required" ) // assigned = attributes.readInto("value", mValue); if (assigned == true) { // check string is not empty and correct syntax if (mValue.empty() == true) { logEmptyString(mValue, getLevel(), getVersion(), "<SpeciesFeatureValue>"); } else if (SyntaxChecker::isValidSBMLSId(mValue) == false && getErrorLog() != NULL) { getErrorLog()->logError(InvalidIdSyntax, getLevel(), getVersion(), "The syntax of the attribute value='" + mValue + "' does not conform."); } } else { std::string message = "Multi attribute 'value' is missing."; getErrorLog()->logPackageError("multi", MultiUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message); } }
/** @cond doxygenLibsbmlInternal */ void Port::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); // look to see whether an unknown attribute error was logged // during the read of the ListOfPorts - which will have // happened immediately prior to this read if (getErrorLog() != NULL && static_cast<ListOfPorts*>(getParentSBMLObject())->size() < 2) { unsigned int numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("comp", CompLOPortsAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("comp", CompLOPortsAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } SBaseRef::readAttributes(attributes,expectedAttributes); if ( sbmlLevel > 2 ) { XMLTriple tripleId("id", mURI, getPrefix()); bool assigned = attributes.readInto(tripleId, mId, getErrorLog(), false, getLine(), getColumn()); if (assigned == false) { logMissingAttribute("id", "<Port>"); } else if (assigned == true && mId.size() == 0) { logEmptyString("id", "<Port>"); } else { if (!SyntaxChecker::isValidSBMLSId(mId)) { logInvalidId("comp:id", mId); } } XMLTriple tripleName("name", mURI, getPrefix()); assigned = attributes.readInto(tripleName, mName, getErrorLog(), false, getLine(), getColumn()); if (assigned == true) { if (mName.empty()) { logEmptyString("name", "<Port>"); } } //LS DEBUG: add an error if the 'port' attribute was used. } }
//----------------------------------------------------------------------------// void Config_xmlHandler::handleImageCodecElement(const XMLAttributes& attr) { d_imageCodecName = attr.getValueAsString(NameAttribute, ""); }
/* * Read values from the given XMLAttributes set into their specific fields. */ void DistribInput::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfDistribInputs - which will have * happened immediately prior to this read */ if (getErrorLog() != NULL && static_cast<ListOfDistribInputs*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("distrib", DistribUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("distrib", DistribUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } SBase::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("distrib", DistribUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("distrib", DistribUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } bool assigned = false; // // id string ( use = "required" ) // assigned = attributes.readInto("id", mId); if (assigned == true) { // check string is not empty if (mId.empty() == true) { logEmptyString(mId, getLevel(), getVersion(), "<DistribInput>"); } } else { std::string message = "Distrib attribute 'id' is missing."; getErrorLog()->logPackageError("distrib", DistribUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message); } // // name string ( use = "optional" ) // assigned = attributes.readInto("name", mName); if (assigned == true) { // check string is not empty if (mName.empty() == true) { logEmptyString(mName, getLevel(), getVersion(), "<DistribInput>"); } } // // index unsigned int ( use = "required" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetIndex = attributes.readInto("index", mIndex); if (mIsSetIndex == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("distrib", DistribUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion); } else { std::string message = "Distrib attribute 'index' is missing."; getErrorLog()->logPackageError("distrib", DistribUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message); } } } }
//----------------------------------------------------------------------------// void Config_xmlHandler::handleDefaultTooltipElement(const XMLAttributes& attr) { d_defaultTooltipType = attr.getValueAsString(NameAttribute, ""); }
/** @cond doxygenLibsbmlInternal */ void Point::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; SBase::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("layout", LayoutPointAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("layout", LayoutPointAllowedCoreAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } bool assigned = false; // // id SId ( use = "optional" ) // assigned = attributes.readInto("id", mId); if (assigned == true && getErrorLog() != NULL) { // check string is not empty and correct syntax if (mId.empty() == true) { logEmptyString(mId, getLevel(), getVersion(), "<Point>"); } else if (SyntaxChecker::isValidSBMLSId(mId) == false) { getErrorLog()->logPackageError("layout", LayoutSIdSyntax, getPackageVersion(), sbmlLevel, sbmlVersion); } } // // x double ( use = "required" ) // numErrs = getErrorLog() != NULL ? getErrorLog()->getNumErrors() : 0; assigned = attributes.readInto("x", mXOffset); if (assigned == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("layout", LayoutPointAttributesMustBeDouble, getPackageVersion(), sbmlLevel, sbmlVersion); } else { std::string message = "Layout attribute 'x' is missing."; getErrorLog()->logPackageError("layout", LayoutPointAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, message); } } } // // y double ( use = "required" ) // numErrs = getErrorLog() != NULL ? getErrorLog()->getNumErrors() : 0; assigned = attributes.readInto("y", mYOffset); if (assigned == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("layout", LayoutPointAttributesMustBeDouble, getPackageVersion(), sbmlLevel, sbmlVersion); } else { std::string message = "Layout attribute 'y' is missing."; getErrorLog()->logPackageError("layout", LayoutPointAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, message); } } } // // z double ( use = "optional" ) // numErrs = getErrorLog() != NULL ? getErrorLog()->getNumErrors() : 0; mZOffsetExplicitlySet = attributes.readInto("z", mZOffset); if (mZOffsetExplicitlySet == false) { mZOffset = 0.0; if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("layout", LayoutPointAttributesMustBeDouble, getPackageVersion(), sbmlLevel, sbmlVersion); } } } }
/** @cond doxygenLibsbmlInternal */ void Submodel::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); // look to see whether an unknown attribute error was logged // during the read of the ListOfSubmodels - which will have // happened immediately prior to this read if (getErrorLog() != NULL && static_cast<ListOfSubmodels*>(getParentSBMLObject())->size() < 2) { unsigned int numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("comp", CompLOSubmodelsAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("comp", CompLOSubmodelsAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } } } CompBase::readAttributes(attributes,expectedAttributes, true, true, CompSubmodelAllowedAttributes); // look to see whether an unknown attribute error was logged SBMLErrorLog* log = getErrorLog(); if (log != NULL) { unsigned int numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs - 1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("comp", CompSubmodelAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("comp", CompSubmodelAllowedCoreAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn()); } } } if ( sbmlLevel > 2 ) { XMLTriple tripleModelRef("modelRef", mURI, getPrefix()); bool assigned = attributes.readInto(tripleModelRef, mModelRef); if (assigned == false) { std::string message = "Comp attribute 'modelRef' is missing."; getErrorLog()->logPackageError("comp", CompSubmodelAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, message, getLine(), getColumn()); } else { if (!SyntaxChecker::isValidSBMLSId(mModelRef)) { logInvalidId("comp:modelRef", mModelRef, "Submodel"); } } XMLTriple tripletcf("timeConversionFactor", mURI, getPrefix()); if (attributes.readInto(tripletcf, mTimeConversionFactor, getErrorLog(), false, getLine(), getColumn())) { if (!SyntaxChecker::isValidSBMLSId(mTimeConversionFactor)) { logInvalidId("comp:timeConversionFactor", mTimeConversionFactor); } } XMLTriple triplexcf("extentConversionFactor", mURI, getPrefix()); if (attributes.readInto(triplexcf, mExtentConversionFactor, getErrorLog(), false, getLine(), getColumn())) { if (!SyntaxChecker::isValidSBMLSId(mExtentConversionFactor)) { logInvalidId("comp:extentConversionFactor", mExtentConversionFactor); } } } }
/** @cond doxygenLibsbmlInternal */ void GeneralGlyph::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfAdditionalGraphicalObjects - which will have * happened immediately prior to this read */ bool loSubGlyphs = false; if (getParentSBMLObject() != NULL && getParentSBMLObject()->getElementName() == "listOfSubGlyphs") { loSubGlyphs = true; } if (getErrorLog() != NULL && static_cast<ListOfGraphicalObjects*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); if (loSubGlyphs == true) { getErrorLog()->logPackageError("layout", LayoutLOSubGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else { getErrorLog()->logPackageError("layout", LayoutLOAddGOAllowedAttribut, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); if (loSubGlyphs == true) { getErrorLog()->logPackageError("layout", LayoutLOSubGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else { getErrorLog()->logPackageError("layout", LayoutLOAddGOAllowedAttribut, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } } GraphicalObject::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("layout", LayoutGGAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("layout", LayoutGGAllowedCoreAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } bool assigned = false; // // reference SIdRef ( use = "optional" ) // assigned = attributes.readInto("reference", mReference); if (assigned == true) { // check string is not empty and correct syntax if (mReference.empty() == true) { logEmptyString(mReference, getLevel(), getVersion(), "<GeneralGlyph>"); } else if (SyntaxChecker::isValidSBMLSId(mReference) == false) { getErrorLog()->logPackageError("layout", LayoutGGReferenceSyntax, getPackageVersion(), sbmlLevel, sbmlVersion); } } }
/* * Read values from the given XMLAttributes set into their specific fields. */ void Output::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfOutputs - which will have * happened immediately prior to this read */ if (getErrorLog() != NULL && static_cast<ListOfOutputs*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("qual", QualTransitionLOOutputAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("qual", QualTransitionLOOutputAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } SBase::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("qual", QualOutputAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("qual", QualOutputAllowedCoreAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } bool assigned = false; // // id SId ( use = "optional" ) // assigned = attributes.readInto("id", mId); if (assigned == true) { // check string is not empty and correct syntax if (mId.empty() == true) { logEmptyString(mId, getLevel(), getVersion(), "<Output>"); } else if (SyntaxChecker::isValidSBMLSId(mId) == false) { logError(InvalidIdSyntax, sbmlLevel, sbmlVersion, "The id '" + mId + "' does not conform to the syntax."); } } // // qualitativeSpecies SIdRef ( use = "required" ) // assigned = attributes.readInto("qualitativeSpecies", mQualitativeSpecies); if (assigned == true) { // check string is not empty and correct syntax if (mQualitativeSpecies.empty() == true) { logEmptyString(mQualitativeSpecies, getLevel(), getVersion(), "<Output>"); } else if (SyntaxChecker::isValidSBMLSId(mQualitativeSpecies) == false) { logError(InvalidIdSyntax, getLevel(), getVersion(), "The syntax of the attribute qualitativeSpecies='" + mQualitativeSpecies + "' does not conform to the syntax."); } } else { std::string message = "Qual attribute 'qualitativeSpecies' is missing."; getErrorLog()->logPackageError("qual", QualOutputAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, message); } // // transitionEffect string ( use = "required" ) // std::string effect; assigned = attributes.readInto("transitionEffect", effect); if (assigned == true) { // check string is not empty if (effect.empty() == true) { logEmptyString(effect, getLevel(), getVersion(), "<Output>"); } else { mTransitionEffect = OutputTransitionEffect_fromString( effect.c_str() ); if (OutputTransitionEffect_isValidOutputTransitionEffect(mTransitionEffect) == 0) { std::string msg = "The transitionEffect on the <output> "; if (isSetId()) { msg += "with id '" + getId() + "' "; } msg += "is '" + effect + "', which is not a valid option."; getErrorLog()->logPackageError("qual", QualOutputTransEffectMustBeOutput, getPackageVersion(), sbmlLevel, sbmlVersion, msg); } } } else { std::string message = "Qual attribute 'transitionEffect' is missing."; getErrorLog()->logPackageError("qual", QualOutputAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, message); } // // name string ( use = "optional" ) // assigned = attributes.readInto("name", mName); if (assigned == true) { // check string is not empty if (mName.empty() == true) { logEmptyString(mName, getLevel(), getVersion(), "<Output>"); } } // // outputLevel int ( use = "optional" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetOutputLevel = attributes.readInto("outputLevel", mOutputLevel); if (mIsSetOutputLevel == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("qual", QualOutputLevelMustBeInteger, getPackageVersion(), sbmlLevel, sbmlVersion); } } } else { if (mOutputLevel < 0) { std::stringstream msg; msg << "The outputLevel of the <output> "; if (isSetId()) { msg << "with id '" << getId() << "' "; } msg << "is '" << mOutputLevel << "', which is negative."; getErrorLog()->logPackageError("qual", QualOutputLevelMustBeNonNegative, getPackageVersion(), sbmlLevel, sbmlVersion, msg.str()); } } }
/* * Read values from the given XMLAttributes set into their specific fields. */ void QualitativeSpecies::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfQualitativeSpeciess - which will have * happened immediately prior to this read */ if (getErrorLog() != NULL && static_cast<ListOfQualitativeSpecies*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("qual", QualLOQualSpeciesAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("qual", QualLOQualSpeciesAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } SBase::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = (int)numErrs-1; n >= 0; n--) { if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("qual", QualQualSpeciesAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError((unsigned int)n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("qual", QualQualSpeciesAllowedCoreAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } bool assigned = false; // // id SId ( use = "required" ) // assigned = attributes.readInto("id", mId); if (assigned == true) { // check string is not empty and correct syntax if (mId.empty() == true) { logEmptyString(mId, getLevel(), getVersion(), "<QualitativeSpecies>"); } else if (SyntaxChecker::isValidSBMLSId(mId) == false) { logError(InvalidIdSyntax, sbmlLevel, sbmlVersion, "The id '" + mId + "' does not conform to the syntax."); } } else { std::string message = "Qual attribute 'id' is missing."; getErrorLog()->logPackageError("qual", QualQualSpeciesAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, message); } // // compartment SIdRef ( use = "required" ) // assigned = attributes.readInto("compartment", mCompartment); if (assigned == true) { // check string is not empty and correct syntax if (mCompartment.empty() == true) { logEmptyString(mCompartment, getLevel(), getVersion(), "<QualitativeSpecies>"); } else if (SyntaxChecker::isValidSBMLSId(mCompartment) == false) { logError(InvalidIdSyntax, getLevel(), getVersion(), "The syntax of the attribute compartment='" + mCompartment + "' does not conform to the syntax."); } } else { std::string message = "Qual attribute 'compartment' is missing."; getErrorLog()->logPackageError("qual", QualQualSpeciesAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, message); } // // constant bool ( use = "required" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetConstant = attributes.readInto("constant", mConstant); if (mIsSetConstant == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("qual", QualConstantMustBeBool, getPackageVersion(), sbmlLevel, sbmlVersion); } else { std::string message = "Qual attribute 'constant' is missing."; getErrorLog()->logPackageError("qual", QualQualSpeciesAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, message); } } } // // name string ( use = "optional" ) // assigned = attributes.readInto("name", mName); if (assigned == true) { // check string is not empty if (mName.empty() == true) { logEmptyString(mName, getLevel(), getVersion(), "<QualitativeSpecies>"); } } // // initialLevel int ( use = "optional" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetInitialLevel = attributes.readInto("initialLevel", mInitialLevel); if (mIsSetInitialLevel == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("qual", QualInitialLevelMustBeInt, getPackageVersion(), sbmlLevel, sbmlVersion); } } } else { if (mInitialLevel < 0) { std::stringstream msg; msg << "The initialLevel of the <qualitativeSpecies> "; if (isSetId()) { msg << "with id '" << getId() << "' "; } msg << "is '" << mInitialLevel << "', which is negative."; getErrorLog()->logPackageError("qual", QualInitalLevelNotNegative, getPackageVersion(), sbmlLevel, sbmlVersion, msg.str()); } } // // maxLevel int ( use = "optional" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetMaxLevel = attributes.readInto("maxLevel", mMaxLevel); if (mIsSetMaxLevel == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("qual", QualMaxLevelMustBeInt, getPackageVersion(), sbmlLevel, sbmlVersion); } } } else { if (mMaxLevel < 0) { std::stringstream msg; msg << "The maxLevel of the <qualitativeSpecies> "; if (isSetId()) { msg << "with id '" << getId() << "' "; } msg << "is '" << mMaxLevel << "', which is negative."; getErrorLog()->logPackageError("qual", QualMaxLevelNotNegative, getPackageVersion(), sbmlLevel, sbmlVersion, msg.str()); } } }
/* * Subclasses should override this method to read values from the given * XMLAttributes set into their specific fields. Be sure to call your * parents implementation of this method as well. */ void NUMLDocument::readAttributes (const XMLAttributes& attributes) { NMBase::readAttributes(attributes); std::vector<std::string> expectedAttributes; expectedAttributes.clear(); expectedAttributes.push_back("level"); expectedAttributes.push_back("version"); expectedAttributes.push_back("metaid"); expectedAttributes.push_back("schemaLocation"); // check that all attributes are expected for (int i = 0; i < attributes.getLength(); i++) { std::vector<std::string>::const_iterator end = expectedAttributes.end(); std::vector<std::string>::const_iterator begin = expectedAttributes.begin(); std::string name = attributes.getName(i); if (std::find(begin, end, name) == end) { logUnknownAttribute(name, getLevel(), getVersion(), "<numl>"); } } // // level: positiveInteger { use="required" fixed="1" } (L1v1) // attributes.readInto("level", mLevel, getErrorLog(), true); // // version: positiveInteger { use="required" fixed="1" } (L1v1, L2v1) // version: positiveInteger { use="required" fixed="2" } (L1v2, L2v2) // version: positiveInteger { use="required" fixed="3" } (L2v3) // attributes.readInto("version", mVersion, getErrorLog(), true); /* check that the level and version are valid */ if (mLevel == 1) { if (mVersion > 2) { logError(InvalidNUMLLevelVersion); } } else { logError(InvalidNUMLLevelVersion); return; } /* check that numl namespace has been set */ unsigned int match = 0; if (mNUMLNamespaces->getNamespaces() == NULL) { logError(NUMLInvalidNamespaceOnNUML); } else { for (int n = 0; n < mNUMLNamespaces->getNamespaces()->getLength(); n++) { if (!strcmp(mNUMLNamespaces->getNamespaces()->getURI(n).c_str(), "http://www.numl.org/numl/level1/version1")) { match = 1; if (mLevel != 1) { logError(NUMLMissingOrInconsistentLevel); } if (mVersion != 1) { logError(NUMLMissingOrInconsistentVersion); } break; } } if (match == 0) { logError(NUMLInvalidNamespaceOnNUML); } else { mNUMLNamespaces->setLevel(mLevel); mNUMLNamespaces->setVersion(mVersion); } } }
/* * Read values from the given XMLAttributes set into their specific fields. */ void ImageData::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; SBase::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } bool assigned = false; // // samplesLength int ( use = "required" ) // numErrs = getErrorLog()->getNumErrors(); mIsSetSamplesLength = attributes.readInto("samplesLength", mSamplesLength); if (mIsSetSamplesLength == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion); } else { std::string message = "Spatial attribute 'samplesLength' is missing."; getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message); } } } // // dataType string ( use = "required" ) // assigned = attributes.readInto("dataType", mDataType); if (assigned == true) { // check string is not empty if (mDataType.empty() == true) { logEmptyString(mDataType, getLevel(), getVersion(), "<ImageData>"); } } else { std::string message = "Spatial attribute 'dataType' is missing."; getErrorLog()->logPackageError("spatial", SpatialUnknownError, getPackageVersion(), sbmlLevel, sbmlVersion, message); } }
XMLNode * RDFAnnotationParser::createCVTerms(const SBase * object) { /* create the basic triples */ XMLTriple li_triple = XMLTriple("li", "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf"); XMLTriple bag_triple = XMLTriple("Bag", "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf"); /* attributes */ XMLAttributes blank_att = XMLAttributes(); /* tokens */ XMLToken bag_token = XMLToken(bag_triple, blank_att); std::string prefix; std::string name; std::string uri; XMLAttributes *resources; XMLNode *description = createRDFDescription(object); /* loop through the cv terms and add */ /* want to add these in blocks of same qualifier */ if (object->getCVTerms()) { for (unsigned int n = 0; n < object->getCVTerms()->getSize(); n++) { if (static_cast <CVTerm *> (object->getCVTerms()->get(n)) ->getQualifierType() == MODEL_QUALIFIER) { prefix = "bqmodel"; uri = "http://biomodels.net/model-qualifiers/"; switch (static_cast <CVTerm *> (object->getCVTerms()->get(n)) ->getModelQualifierType()) { case BQM_IS: name = "is"; break; case BQM_IS_DESCRIBED_BY: name = "isDescribedBy"; break; case BQM_UNKNOWN: return NULL; break; } } else if (static_cast <CVTerm *> (object->getCVTerms()->get(n)) ->getQualifierType() == BIOLOGICAL_QUALIFIER) { prefix = "bqbiol"; uri = "http://biomodels.net/biological-qualifiers/"; switch (static_cast <CVTerm *> (object->getCVTerms()->get(n)) ->getBiologicalQualifierType()) { case BQB_IS: name = "is"; break; case BQB_HAS_PART: name = "hasPart"; break; case BQB_IS_PART_OF: name = "isPartOf"; break; case BQB_IS_VERSION_OF: name = "isVersionOf"; break; case BQB_HAS_VERSION: name = "hasVersion"; break; case BQB_IS_HOMOLOG_TO: name = "isHomologTo"; break; case BQB_IS_DESCRIBED_BY: name = "isDescribedBy"; break; case BQB_IS_ENCODED_BY: name = "isEncodedBy"; break; case BQB_ENCODES: name = "encodes"; break; case BQB_OCCURS_IN: name = "occursIn"; break; case BQB_UNKNOWN: return NULL; break; } } else { continue; } resources = static_cast <CVTerm *> (object->getCVTerms()->get(n)) ->getResources(); XMLNode bag(bag_token); for (int r = 0; r < resources->getLength(); r++) { XMLAttributes att; att.add(resources->getName(r), resources->getValue(r)); XMLToken li_token(li_triple, att); li_token.setEnd(); XMLNode li(li_token); bag.addChild(li); } XMLTriple type_triple(name, uri, prefix); XMLToken type_token(type_triple, blank_att); XMLNode type(type_token); type.addChild(bag); description->addChild(type); } } return description; }
/** @cond doxygenLibsbmlInternal */ void CompartmentGlyph::readAttributes (const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes) { const unsigned int sbmlLevel = getLevel (); const unsigned int sbmlVersion = getVersion(); unsigned int numErrs; /* look to see whether an unknown attribute error was logged * during the read of the listOfCompartmentGlyphs - which will have * happened immediately prior to this read */ bool loSubGlyphs = false; if (getParentSBMLObject() != NULL && getParentSBMLObject()->getElementName() == "listOfSubGlyphs") { loSubGlyphs = true; } if (getErrorLog() != NULL && static_cast<ListOfCompartmentGlyphs*>(getParentSBMLObject())->size() < 2) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); if (loSubGlyphs == true) { getErrorLog()->logPackageError("layout", LayoutLOSubGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else { getErrorLog()->logPackageError("layout", LayoutLOCompGlyphAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); if (loSubGlyphs == true) { getErrorLog()->logPackageError("layout", LayoutLOSubGlyphAllowedAttribs, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else { getErrorLog()->logPackageError("layout", LayoutLOCompGlyphAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } } GraphicalObject::readAttributes(attributes, expectedAttributes); // look to see whether an unknown attribute error was logged if (getErrorLog() != NULL) { numErrs = getErrorLog()->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (getErrorLog()->getError(n)->getErrorId() == UnknownPackageAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownPackageAttribute); getErrorLog()->logPackageError("layout", LayoutCGAllowedAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } else if (getErrorLog()->getError(n)->getErrorId() == UnknownCoreAttribute) { const std::string details = getErrorLog()->getError(n)->getMessage(); getErrorLog()->remove(UnknownCoreAttribute); getErrorLog()->logPackageError("layout", LayoutCGAllowedCoreAttributes, getPackageVersion(), sbmlLevel, sbmlVersion, details); } } } bool assigned = false; // // compartment SIdRef ( use = "optional" ) // assigned = attributes.readInto("compartment", mCompartment); if (assigned == true) { if (getErrorLog() != NULL) { // check string is not empty and correct syntax if (mCompartment.empty() == true) { logEmptyString(mCompartment, getLevel(), getVersion(), "<CompartmentGlyph>"); } else if (SyntaxChecker::isValidSBMLSId(mCompartment) == false) { getErrorLog()->logPackageError("layout", LayoutCGCompartmentSyntax, getPackageVersion(), sbmlLevel, sbmlVersion); } } } // // order double ( use = "optional" ) // if (getErrorLog() != NULL) numErrs = getErrorLog()->getNumErrors(); mIsSetOrder = attributes.readInto("order", mOrder); if (mIsSetOrder == false) { if (getErrorLog() != NULL) { if (getErrorLog()->getNumErrors() == numErrs + 1 && getErrorLog()->contains(XMLAttributeTypeMismatch)) { getErrorLog()->remove(XMLAttributeTypeMismatch); getErrorLog()->logPackageError("layout", LayoutCGOrderMustBeDouble, getPackageVersion(), sbmlLevel, sbmlVersion); } } } }