diff --git a/deviser/base_files/BaseTexFile.py b/deviser/base_files/BaseTexFile.py index d0eeae274..20999604f 100644 --- a/deviser/base_files/BaseTexFile.py +++ b/deviser/base_files/BaseTexFile.py @@ -39,8 +39,8 @@ # ------------------------------------------------------------------------ --> +from ..util import global_variables, strFunctions from . import BaseFile -from ..util import strFunctions class BaseTexFile(BaseFile.BaseFile): @@ -57,27 +57,40 @@ def __init__(self, name, extension, object_desc): BaseFile.BaseFile.__init__(self, name, extension) # change the comment delimiter and line length - self.comment = '%' + self.comment = "%" self.line_length = 72 - self.package = object_desc['name'] - self.fullname = object_desc['fullname'] - self.sbml_classes = object_desc['baseElements'] - self.offset = object_desc['offset'] - self.plugins = object_desc['plugins'] - self.enums = object_desc['enums'] - self.level = object_desc['base_level'] - self.version = object_desc['base_version'] - self.pkg_version = object_desc['pkg_version'] - if object_desc['required']: - self.reqd_status = 'true' + if global_variables.is_sbml: + self.package = object_desc["name"] + self.fullname = object_desc["fullname"] + self.sbml_classes = object_desc["baseElements"] + self.offset = object_desc["offset"] + self.plugins = object_desc["plugins"] + self.enums = object_desc["enums"] + self.level = object_desc["base_level"] + self.version = object_desc["base_version"] + self.pkg_version = object_desc["pkg_version"] + if object_desc["required"]: + self.reqd_status = "true" + else: + self.reqd_status = "false" else: - self.reqd_status = 'false' + self.package = '' + self.fullname = global_variables.package_full_name + self.sbml_classes = object_desc["baseElements"] + self.offset = object_desc["offset"] + self.plugins = [] + self.enums = object_desc["enums"] + self.level = object_desc["base_level"] + self.version = object_desc["base_version"] + self.pkg_version = 0 + self.reqd_status = "false" + self.prim_class = [] - self.start_b = '{' - self.end_b = '}' + self.start_b = "{" + self.end_b = "}" # expand the information for the classes self.fulltexname = strFunctions.texify(self.fullname) @@ -86,8 +99,12 @@ def __init__(self, name, extension, object_desc): self.sort_attribute_names(self.sbml_classes) self.sort_enum_names(self.enums) - self.full_pkg_command = '\\{0}Package'.format(self.fulltexname) - self.brief_pkg_command = '\\{0}'.format(self.upper_package) + if global_variables.is_sbml: + self.full_pkg_command = "\\{0}Package".format(self.fulltexname) + else: + self.full_pkg_command = "\\{0}".format(self.fulltexname) + + self.brief_pkg_command = "\\{0}".format(self.upper_package) ######################################################################## @@ -99,14 +116,14 @@ def sort_class_names(self, classes): """ if classes is not None: for i in range(0, len(classes)): - name = classes[i]['name'] + name = classes[i]["name"] texname = strFunctions.texify(name) - classes[i]['texname'] = texname + classes[i]["texname"] = texname # hack for render - if name == 'Ellipse' or name == 'Rectangle': - texname = 'Render' + name - classes[i]['texname'] = texname - if name == 'RelAbsVector': + if name == "Ellipse" or name == "Rectangle": + texname = "Render" + name + classes[i]["texname"] = texname + if name == "RelAbsVector": self.prim_class.append(classes[i]) @staticmethod @@ -118,28 +135,12 @@ def sort_attribute_names(classes): """ if classes is not None: for i in range(0, len(classes)): - attribs = classes[i]['attribs'] + attribs = classes[i]["attribs"] BaseTexFile.update_attrib_dicts(attribs) - # for j in range(0, len(attribs)): - # if attribs[j]['type'] in ['lo_element', 'element', - # 'inline_lo_element']: - # name = attribs[j]['element'] - # else: - # name = attribs[j]['name'] - # texname = strFunctions.texify(name) - # attribs[j]['texname'] = texname for i in range(0, len(classes)): - if 'lo_attribs' in classes[i]: - lo_attribs = classes[i]['lo_attribs'] + if "lo_attribs" in classes[i]: + lo_attribs = classes[i]["lo_attribs"] BaseTexFile.update_attrib_dicts(lo_attribs) - # for j in range(0, len(lo_attribs)): - # if lo_attribs[j]['type'] in ['lo_element', 'element', - # 'inline_lo_element']: - # name = lo_attribs[j]['element'] - # else: - # name = lo_attribs[j]['name'] - # texname = strFunctions.texify(name) - # lo_attribs[j]['texname'] = texname @staticmethod def update_attrib_dicts(my_list): @@ -149,13 +150,12 @@ def update_attrib_dicts(my_list): :param my_list: the list which we update. """ for j in range(0, len(my_list)): - if my_list[j]['type'] in ['lo_element', 'element', - 'inline_lo_element']: - name = my_list[j]['element'] + if my_list[j]["type"] in ["lo_element", "element", "inline_lo_element"]: + name = my_list[j]["element"] else: - name = my_list[j]['name'] + name = my_list[j]["name"] texname = strFunctions.texify(name) - my_list[j]['texname'] = texname + my_list[j]["texname"] = texname @staticmethod def sort_enum_names(enums): @@ -166,9 +166,9 @@ def sort_enum_names(enums): """ if enums is not None: for i in range(0, len(enums)): - name = enums[i]['name'] + name = enums[i]["name"] texname = strFunctions.texify(name) - enums[i]['texname'] = texname + enums[i]["texname"] = texname def write_to_do(self, text): """ @@ -177,8 +177,7 @@ def write_to_do(self, text): :param text: the text describing the TODO. """ - self.write_text_line('\\TODO{0}{1}{2}'.format(self.start_b, text, - self.end_b)) + self.write_text_line("\\TODO{0}{1}{2}".format(self.start_b, text, self.end_b)) self.skip_line() def write_text_line(self, line): diff --git a/deviser/code_files/ExtensionHeaderFile.py b/deviser/code_files/ExtensionHeaderFile.py index 8ba06b5e0..afde01b86 100644 --- a/deviser/code_files/ExtensionHeaderFile.py +++ b/deviser/code_files/ExtensionHeaderFile.py @@ -419,6 +419,10 @@ def write_all_elements(self): prefixed_name = '{0}{1}'.format(global_variables.prefix, name) new_element = dict({'name': prefixed_name}) elements.append(new_element) + others = ['List', 'ListNode', 'ExpectedAttributes'] + for name in others: + new_element = dict({'name': name}) + elements.append(new_element) self.write_classes(elements) new_length = len(elements) for i in range(new_length, no_elements, -1): @@ -483,7 +487,8 @@ def write_fwd_file(self): self.write_cppns_end() # if we are in another library and using either ASTNode or XMLNode # we need to declare these here - if global_variables.uses_ASTNode or global_variables.uses_XMLNode: + # don't need xmlnode for now + if global_variables.uses_ASTNode: self.write_libsbml_fwd() self.write_end_class_or_struct() self.write_defn_end() diff --git a/deviser/code_files/OtherLibraryFiles.py b/deviser/code_files/OtherLibraryFiles.py index bd78ce20c..0431846c2 100644 --- a/deviser/code_files/OtherLibraryFiles.py +++ b/deviser/code_files/OtherLibraryFiles.py @@ -428,9 +428,9 @@ def print_document_errors(self, fileout): docname = SF.remove_prefix(doc['name'], remove_package=False, remove_doc_prefix=True) libname = SF.get_library_suffix(gv.library_name) - if not libname.endswith('ml'): - libname = libname + 'ml' - fileout.copy_line_verbatim((10 * '') + 'if ( errorId == {0}{1}Allowed' +# if not libname.endswith('ml'): +# libname = libname + 'ml' + fileout.copy_line_verbatim((10 * ' ') + 'if ( errorId == {0}{1}Allowed' 'CoreAttributes\n'.format(libname, docname)) level = False version = False diff --git a/deviser/code_files/ValidationFiles.py b/deviser/code_files/ValidationFiles.py index e28f5d7d3..60b63859e 100644 --- a/deviser/code_files/ValidationFiles.py +++ b/deviser/code_files/ValidationFiles.py @@ -106,13 +106,15 @@ def create_rule_structure(self): rules = ValidationRulesGeneral\ .ValidationRulesGeneral(self.fullname, number, self.package, self.pkg_ref, self.level, self.version, - self.pkg_version, self.reqd_status) + self.pkg_version, self.reqd_status, + global_variables.language) rules.determine_rules() self.class_rules += rules.rules - if global_variables.is_package: - number = self.offset + 20200 - else: - number = 20200 + number = self.offset + 20200 if global_variables.is_sbml else 20100 +# if global_variables.is_package: +# number = self.offset + 20200 +# else: +# number = 20200 for i in range(0, len(self.plugins)): rules = ValidationRulesForPlugin.ValidationRulesForPlugin( self.plugins[i], self.fullname, number, @@ -130,6 +132,15 @@ def create_rule_structure(self): self.pkg_ref) rules.determine_rules() self.class_rules += rules.rules + if not global_variables.is_sbml: + for att in self.sbml_classes[i]['attribs']: + if att['type'] == 'lo_element': + rules.rules = [] + number += 100 + rules.number = number + rules.add_lo_rules() + self.class_rules += rules.rules + number += 100 self.populate_error_list() @@ -437,10 +448,14 @@ def is_package(i, text_string, length): is_package = True return [is_package, len_word] - @staticmethod - def replace_name(i, text_string, length): + def replace_name(self, i, text_string, length): in_name = True return_name_rep = '' + # we dont want to lower the s of SBase + # or name if it starts with the prefix for the language + isSBase = False + is_language_prefix = False + num_letters = 0 while in_name and i < length: letter = text_string[i] if i != length-1: @@ -448,17 +463,21 @@ def replace_name(i, text_string, length): else: next_letter = ' ' if letter == '\\': - isSBase = False - # we dont want to lower the s of SBase - if next_letter == 'S' or next_letter == 's': - test_str = text_string[i+1:i+7] - if test_str.lower() == 'sbase ': - isSBase = True + if global_variables.is_sbml: + isSBase = self.is_sbase(text_string, i, next_letter) + else: + [is_language_prefix, num_letters] = self.is_language_prefix(text_string, i, next_letter) if isSBase: return_name_rep += '\'S' + i += 1 + elif is_language_prefix: + return_name_rep += '<' + for j in range(0, num_letters): + return_name_rep += '{0}'.format(text_string[i + j + 1].upper()) + i += num_letters else: return_name_rep += '<{0}'.format(next_letter.lower()) - i += 1 + i += 1 elif next_letter == ' ' or next_letter == '.': if isSBase: return_name_rep += '{0}\''.format(letter) @@ -471,6 +490,27 @@ def replace_name(i, text_string, length): continue return [i-1, return_name_rep] + def is_language_prefix(self, text, index, next_letter): + prefix = global_variables.language.upper() + if not prefix.startswith(next_letter): + return [False, 0] + length_prefix = len(prefix) + match = True + for i in range(0, length_prefix): + if prefix[i] != text[index + i + 1]: + match = False + return [match, length_prefix] + + @staticmethod + def is_sbase(text, index, next_letter): + if len(text) < index + 7: + return False + if next_letter == 'S' or next_letter == 's': + test_str = text[index + 1:index + 7] + if test_str.lower() == 'sbase ': + return True + return False + @staticmethod def replace_uri(i, text_string, length): in_uri = True diff --git a/deviser/code_files/templates/ConstructorException.h b/deviser/code_files/templates/ConstructorException.h index 9ef7cbc57..9aa1fd98b 100644 --- a/deviser/code_files/templates/ConstructorException.h +++ b/deviser/code_files/templates/ConstructorException.h @@ -1,7 +1,7 @@ #ifndef SBML_CONSTRUCTOR_EXCEPTION_H #define SBML_CONSTRUCTOR_EXCEPTION_H -#include +#include #include #ifdef __cplusplus diff --git a/deviser/code_files/templates/Error.h b/deviser/code_files/templates/Error.h index bc429fdee..24fe012ba 100644 --- a/deviser/code_files/templates/Error.h +++ b/deviser/code_files/templates/Error.h @@ -1,7 +1,7 @@ #ifndef SBMLError_h #define SBMLError_h -#include +#include #include @@ -21,17 +21,6 @@ typedef enum , SBMLNotUTF8 = 10001 /*!< File does not use UTF-8 encoding. */ , SBMLUnrecognizedElement = 10002 /*!< Encountered unrecognized element. */ , SBMLNotSchemaConformant = 10003 /*!< Document does not conform to the SBML_Lang XML schema. */ -, SBMLInvalidMathElement = 10201 -, SBMLMissingNamespace = 10401 /*!< Missing declaration of the XML namespace for the annotation. */ -, SBMLDuplicateNamespaces = 10402 /*!< Multiple annotations using the same XML namespace. */ -, SBMLNamespaceIn = 10403 /*!< The SBML_Lang XML namespace cannot be used in an object. */ -, SBMLMultiples = 10404 /*!< Only one object is permitted under a given SBML_Lang object. */ -, SBMLNotElement = 10405 -, SBMLNotesNotInXHTMLNamespace = 10801 /*!< Notes must be placed in the XHTML XML namespace. */ -, SBMLNotesContainsXMLDecl = 10802 /*!< XML declarations are not permitted in Notes objects. */ -, SBMLNotesContainsDOCTYPE = 10803 /*!< XML DOCTYPE elements are not permitted in Notes objects. */ -, SBMLInvalidNotesContent = 10804 /*!< Invalid notes content found. */ -, SBMLOnlyOneNotesElementAllowed = 10805 /*!< Only one Notes subobject is permitted on a given SBML_Lang object. */ , SBMLUnknownCoreAttribute = 99994 /*!< Encountered an unknown attribute in the SBML_Lang Core namespace. */ , SBMLCodesUpperBound = 99999 /*!< Upper boundary of libSBML-specific diagnostic codes. */ diff --git a/deviser/code_files/templates/ErrorLog.h b/deviser/code_files/templates/ErrorLog.h index 1b736c517..78c481fc4 100644 --- a/deviser/code_files/templates/ErrorLog.h +++ b/deviser/code_files/templates/ErrorLog.h @@ -4,8 +4,8 @@ #include -#include -#include +#include +#include #include diff --git a/deviser/code_files/templates/ErrorTable.h b/deviser/code_files/templates/ErrorTable.h index ea8e1021d..8fb21fc11 100644 --- a/deviser/code_files/templates/ErrorTable.h +++ b/deviser/code_files/templates/ErrorTable.h @@ -77,126 +77,6 @@ static const sbmlErrorTableEntry sbmlErrorTable[] = } }, - //10201 - { - SBMLInvalidMathElement, - "Invalid MathML", - LIBSBML_CAT_MATHML_CONSISTENCY, - LIBSBML_SEV_ERROR, - "All MathML content in SBML_Lang must appear within a element, and the " - " element must be either explicitly or implicitly in the XML " - "namespace \"http://www.w3.org/1998/Math/MathML\".", - {"" - } - }, - - //10401 - { - SBMLMissingNamespace, - "Missing declaration of the XML namespace for the annotation", - LIBSBML_CAT_SBML, - LIBSBML_SEV_ERROR, - "Every top-level element within an annotation element must " - "have a namespace declared.", - {"" - } - }, - - //10402 - { - SBMLDuplicateNamespaces, - "Multiple annotations using the same XML namespace", - LIBSBML_CAT_SBML, - LIBSBML_SEV_ERROR, - "There cannot be more than one top-level element using a " - "given namespace inside a given annotation element. ", - {"" - } - }, - - //10403 - { - SBMLNamespaceIn, - "The SBML_Lang XML namespace cannot be used in an object", - LIBSBML_CAT_SBML, - LIBSBML_SEV_ERROR, - "Top-level elements within an annotation element cannot use any SBML_Lang " - "namespace, whether explicitly or implicitly (by failing " - "to declare any namespace).", - {"" - } - }, - - //10404 - { - SBMLMultiples, - "Only one object is permitted under a given SBML_Lang object", - LIBSBML_CAT_SBML, - LIBSBML_SEV_ERROR, - "A given SBML_Lang object may contain at most one element.", - {"" - } - }, - - //10801 - { - SBMLNotesNotInXHTMLNamespace, - "Notes must be placed in the XHTML XML namespace", - LIBSBML_CAT_SBML, - LIBSBML_SEV_ERROR, - "The contents of the element must be explicitly placed in the " - "XHTML XML namespace.", - {"" - } - }, - - //10802 - { - SBMLNotesContainsXMLDecl, - "XML declarations are not permitted in Notes objects", - LIBSBML_CAT_SBML, - LIBSBML_SEV_ERROR, - "The contents of the element must not contain an XML declaration " - "(i.e., a string of the form \"\" " - "or similar).", - {"" - } - }, - - //10803 - { - SBMLNotesContainsDOCTYPE, - "XML DOCTYPE elements are not permitted in Notes objects", - LIBSBML_CAT_SBML, - LIBSBML_SEV_ERROR, - "The contents of the element must not contain an XML DOCTYPE " - "declaration (i.e., a string beginning with the characters \" element. ", - {"" - } - }, - - //10805 - { - SBMLOnlyOneNotesElementAllowed, - "Only one Notes subobject is permitted on a given SBML_Lang object", - LIBSBML_CAT_SBML, - LIBSBML_SEV_ERROR, - "A given SBML_Lang object may contain at most one element. ", - {"" - } - }, - /* -------------------------------------------------------------------------- * Boundary marker. SBML_Lang specific errors. * ----------------------------------------------------------------------- */ diff --git a/deviser/code_files/templates/Namespaces.cpp b/deviser/code_files/templates/Namespaces.cpp index e0abe1ddc..33560e13c 100644 --- a/deviser/code_files/templates/Namespaces.cpp +++ b/deviser/code_files/templates/Namespaces.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include /** @cond doxygenIgnored */ @@ -400,7 +400,7 @@ LIBSBML_EXTERN char * SBMLNamespaces_getSBMLNamespaceURI(unsigned int level, unsigned int version) { - return safe_strdup(SBMLNamespaces::getSBMLNamespaceURI(level, version).c_str()); + return sbml_safe_strdup(SBMLNamespaces::getSBMLNamespaceURI(level, version).c_str()); } diff --git a/deviser/code_files/templates/Namespaces.h b/deviser/code_files/templates/Namespaces.h index 5ecf2c42d..864ae2545 100644 --- a/deviser/code_files/templates/Namespaces.h +++ b/deviser/code_files/templates/Namespaces.h @@ -1,13 +1,12 @@ #ifndef SBMLNamespaces_h #define SBMLNamespaces_h - #include -#include - +#include -#include -#include + +#include +#include #ifdef __cplusplus namespace LIBSBML_CPP_NAMESPACE diff --git a/deviser/code_files/templates/Reader.cpp b/deviser/code_files/templates/Reader.cpp index 7cda76268..498800284 100644 --- a/deviser/code_files/templates/Reader.cpp +++ b/deviser/code_files/templates/Reader.cpp @@ -180,7 +180,7 @@ SBMLReader::readInternal (const char* content, bool isFile) { SBMLDocument* d = new SBMLDocument(); - if (isFile && content != NULL && (util_file_exists(content) == false)) + if (isFile && content != NULL && (sbml_util_file_exists(content) == false)) { d->getErrorLog()->logError(XMLFileUnreadable); } @@ -232,7 +232,7 @@ SBMLReader::readInternal (const char* content, bool isFile) { d->getErrorLog()->logError(MissingXMLEncoding); } - else if (strcmp_insensitive(stream.getEncoding().c_str(), "UTF-8") != 0) + else if (sbml_strcmp_insensitive(stream.getEncoding().c_str(), "UTF-8") != 0) { d->getErrorLog()->logError(SBMLNotUTF8); } @@ -241,7 +241,7 @@ SBMLReader::readInternal (const char* content, bool isFile) { d->getErrorLog()->logError(BadXMLDecl); } - else if (strcmp_insensitive(stream.getVersion().c_str(), "1.0") != 0) + else if (sbml_strcmp_insensitive(stream.getVersion().c_str(), "1.0") != 0) { d->getErrorLog()->logError(BadXMLDecl); } diff --git a/deviser/code_files/templates/Reader.h b/deviser/code_files/templates/Reader.h index 9c1ca2629..dab882c2a 100644 --- a/deviser/code_files/templates/Reader.h +++ b/deviser/code_files/templates/Reader.h @@ -2,11 +2,8 @@ #define SBMLReader_h -#include -#include - -#include - +#include +#include #ifdef __cplusplus diff --git a/deviser/code_files/templates/SBase.cpp b/deviser/code_files/templates/SBase.cpp index 27bcc52d3..6b2c7da42 100644 --- a/deviser/code_files/templates/SBase.cpp +++ b/deviser/code_files/templates/SBase.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include @@ -148,12 +147,12 @@ SBase::SBase(const SBase& orig) , mURI(orig.mURI) { if(orig.m != NULL) - this->m = new XMLNode(*const_cast(orig).get()); + this->m = new XMLNode(*const_cast(orig).get()); else this->m = NULL; if(orig.m != NULL) - this->m = new XMLNode(*const_cast(orig).m); + this->m = new XMLNode(*const_cast(orig).m); else this->m = NULL; @@ -191,14 +190,14 @@ SBase& SBase::operator=(const SBase& rhs) delete this->m; if(rhs.m != NULL) - this->m = new XMLNode(*const_cast(rhs).get()); + this->m = new XMLNode(*const_cast(rhs).get()); else this->m = NULL; delete this->m; if(rhs.m != NULL) - this->m = new XMLNode(*const_cast(rhs).m); + this->m = new XMLNode(*const_cast(rhs).m); else this->m = NULL; @@ -254,14 +253,14 @@ SBase::getId() const /* * @return the notes of this SBML_Lang object. */ -XMLNode* +XMLNode* SBase::get() { return m; } -const XMLNode* +const XMLNode* SBase::get() const { return m; @@ -274,28 +273,28 @@ SBase::get() const std::string SBase::getString() { - return XMLNode::convertXMLNodeToString(m); + return XMLNode::convertXMLNodeToString(m); } std::string SBase::getString() const { - return XMLNode::convertXMLNodeToString(m); + return XMLNode::convertXMLNodeToString(m); } /* * @return the annotation of this SBML_Lang object. */ -XMLNode* +XMLNode* SBase::get () { return m; } -const XMLNode* +const XMLNode* SBase::get () const { return const_cast(this)->get(); @@ -308,14 +307,14 @@ SBase::get () const std::string SBase::getString () { - return XMLNode::convertXMLNodeToString(get()); + return XMLNode::convertXMLNodeToString(get()); } std::string SBase::getString () const { - return XMLNode::convertXMLNodeToString(get()); + return XMLNode::convertXMLNodeToString(get()); } @@ -393,7 +392,7 @@ SBase::unsetUserData() /* * @return the Namespaces associated with this SBML_Lang object */ -XMLNamespaces* +XMLNamespaces* SBase::getNamespaces() { if (mSBML != NULL) @@ -403,7 +402,7 @@ SBase::getNamespaces() } -const XMLNamespaces* +const XMLNamespaces* SBase::getNamespaces() const { if (mSBML != NULL) @@ -597,10 +596,6 @@ SBase::setMetaId (const std::string& metaid) mMetaId.erase(); return LIBSBML_OPERATION_SUCCESS; } - else if (!(SyntaxChecker::isValidXMLID(metaid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mMetaId = metaid; @@ -619,10 +614,6 @@ SBase::setId (const std::string& sid) mId.erase(); return LIBSBML_OPERATION_SUCCESS; } - else if (!(SyntaxChecker::isValidXMLID(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mId = sid; @@ -635,7 +626,7 @@ SBase::setId (const std::string& sid) * Sets the annotation of this SBML_Lang object to a copy of annotation. */ int -SBase::set (XMLNode* annotation) +SBase::set (XMLNode* annotation) { if (annotation == NULL) { @@ -668,17 +659,17 @@ SBase::set (const std::string& annotation) return LIBSBML_OPERATION_SUCCESS; } - XMLNode* annt_xmln; + XMLNode* annt_xmln; // you might not have a document !! if (getSBMLDocument() != NULL) { - XMLNamespaces* xmlns = getSBMLDocument()->getNamespaces(); - annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); + XMLNamespaces* xmlns = getSBMLDocument()->getNamespaces(); + annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); } else { - annt_xmln = XMLNode::convertStringToXMLNode(annotation); + annt_xmln = XMLNode::convertStringToXMLNode(annotation); } if(annt_xmln != NULL) @@ -696,7 +687,7 @@ SBase::set (const std::string& annotation) * adding additional information. */ int -SBase::append (const XMLNode* annotation) +SBase::append (const XMLNode* annotation) { int success = LIBSBML_OPERATION_FAILED; unsigned int duplicates = 0; @@ -704,14 +695,14 @@ SBase::append (const XMLNode* annotation) if(annotation == NULL) return LIBSBML_OPERATION_SUCCESS; - XMLNode* new_annotation = NULL; + XMLNode* new_annotation = NULL; const string& name = annotation->getName(); // check for annotation tags and add if necessary if (name != ) { - XMLToken ann_t = XMLToken(XMLTriple(, "", ""), XMLAttributes()); - new_annotation = new XMLNode(ann_t); + XMLToken ann_t = XMLToken(XMLTriple(, "", ""), XMLAttributes()); + new_annotation = new XMLNode(ann_t); new_annotation->addChild(*annotation); } else @@ -760,7 +751,7 @@ SBase::append (const XMLNode* annotation) } else { - XMLNode *copy = m->clone(); + XMLNode *copy = m->clone(); success = set(copy); delete copy; } @@ -786,15 +777,15 @@ int SBase::append (const std::string& annotation) { int success = LIBSBML_OPERATION_FAILED; - XMLNode* annt_xmln; + XMLNode* annt_xmln; if (getSBMLDocument() != NULL) { - XMLNamespaces* xmlns = getSBMLDocument()->getNamespaces(); - annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); + XMLNamespaces* xmlns = getSBMLDocument()->getNamespaces(); + annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); } else { - annt_xmln = XMLNode::convertStringToXMLNode(annotation); + annt_xmln = XMLNode::convertStringToXMLNode(annotation); } if(annt_xmln != NULL) @@ -831,7 +822,7 @@ SBase::removeTopLevelElement(const std::string elementName, // check uri matches if (elementURI.empty() == false) { - XMLNode child = m->getChild(index); + XMLNode child = m->getChild(index); std::string prefix = child.getPrefix(); if (prefix.empty() == false @@ -883,10 +874,10 @@ SBase::removeTopLevelElement(const std::string elementName, int -SBase::replaceTopLevelElement(const XMLNode* annotation) +SBase::replaceTopLevelElement(const XMLNode* annotation) { int success = LIBSBML_OPERATION_FAILED; - XMLNode * replacement = NULL; + XMLNode * replacement = NULL; if (annotation->getName() == ) { if (annotation->getNumChildren() != 1) @@ -920,15 +911,15 @@ int SBase::replaceTopLevelElement(const std::string& annotation) { int success = LIBSBML_OPERATION_FAILED; - XMLNode* annt_xmln; + XMLNode* annt_xmln; if (getSBMLDocument() != NULL) { - XMLNamespaces* xmlns = getSBMLDocument()->getNamespaces(); - annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); + XMLNamespaces* xmlns = getSBMLDocument()->getNamespaces(); + annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); } else { - annt_xmln = XMLNode::convertStringToXMLNode(annotation); + annt_xmln = XMLNode::convertStringToXMLNode(annotation); } if(annt_xmln != NULL) @@ -946,7 +937,7 @@ SBase::replaceTopLevelElement(const std::string& annotation) * Sets the notes of this SBML_Lang object to a copy of notes. */ int -SBase::set(const XMLNode* notes) +SBase::set(const XMLNode* notes) { if (m == notes) { @@ -966,13 +957,13 @@ SBase::set(const XMLNode* notes) if (name == "notes") { - m = static_cast<XMLNode*>( notes->clone() ); + m = static_cast( notes->clone() ); } else { - XMLToken notes_t = XMLToken(XMLTriple("notes", "", ""), - XMLAttributes()); - m = new XMLNode(notes_t); + XMLToken notes_t = XMLToken(XMLTriple("notes", "", ""), + XMLAttributes()); + m = new XMLNode(notes_t); // The root node of the given XMLNode tree can be an empty XMLNode // (i.e. neither start, end, nor text XMLNode) if the given notes was @@ -996,13 +987,6 @@ SBase::set(const XMLNode* notes) } } - if (!SyntaxChecker::hasExpectedXHTMLSyntax(m, NULL)) - { - delete m; - m = NULL; - return LIBSBML_INVALID_OBJECT; - } - return LIBSBML_OPERATION_SUCCESS; } @@ -1021,17 +1005,17 @@ SBase::set(const std::string& notes, bool addXHTMLMarkup) } else { - XMLNode* notes_xmln; + XMLNode* notes_xmln; // you might not have a document !! if (getSBMLDocument() != NULL) { - XMLNamespaces* xmlns = getSBMLDocument()->getNamespaces(); - notes_xmln = XMLNode::convertStringToXMLNode(notes,xmlns); + XMLNamespaces* xmlns = getSBMLDocument()->getNamespaces(); + notes_xmln = XMLNode::convertStringToXMLNode(notes,xmlns); } else { - notes_xmln = XMLNode::convertStringToXMLNode(notes); + notes_xmln = XMLNode::convertStringToXMLNode(notes); } if (notes_xmln != NULL) @@ -1044,11 +1028,11 @@ SBase::set(const std::string& notes, bool addXHTMLMarkup) && notes_xmln->isText() == true) { //create a parent node of xhtml type p - XMLAttributes blank_att = XMLAttributes(); - XMLTriple triple = XMLTriple("p", "http://www.w3.org/1999/xhtml", ""); - XMLNamespaces xmlns = XMLNamespaces(); + XMLAttributes blank_att = XMLAttributes(); + XMLTriple triple = XMLTriple("p", "http://www.w3.org/1999/xhtml", ""); + XMLNamespaces xmlns = XMLNamespaces(); xmlns.add("http://www.w3.org/1999/xhtml", ""); - XMLNode *xmlnode = new XMLNode(XMLToken(triple, blank_att, xmlns)); + XMLNode *xmlnode = new XMLNode(XMLToken(triple, blank_att, xmlns)); // create a text node from the text given xmlnode->addChild(*notes_xmln); @@ -1078,7 +1062,7 @@ SBase::set(const std::string& notes, bool addXHTMLMarkup) * adding additional information. */ int -SBase::append(const XMLNode* notes) +SBase::append(const XMLNode* notes) { int success = LIBSBML_OPERATION_FAILED; if(notes == NULL) @@ -1107,7 +1091,7 @@ SBase::append(const XMLNode* notes) typedef enum { _AHTML, _ABody, _AAny } _Type; _Type addedType = _AAny; - XMLNode added; + XMLNode added; //------------------------------------------------------------ // @@ -1218,7 +1202,7 @@ SBase::append(const XMLNode* notes) if (getLevel() > 2 || (getLevel() == 2 && getVersion() > 1)) { - XMLNode tmp(XMLTriple("notes","",""), XMLAttributes()); + XMLNode tmp(XMLTriple("notes","",""), XMLAttributes()); if (addedType == _AAny) { @@ -1231,15 +1215,9 @@ SBase::append(const XMLNode* notes) { tmp.addChild(added); } - - if (!SyntaxChecker::hasExpectedXHTMLSyntax(&tmp, NULL)) - { - return LIBSBML_INVALID_OBJECT; - } } - - if ( m != NULL ) + if (m != NULL) { //------------------------------------------------------------ // @@ -1248,7 +1226,7 @@ SBase::append(const XMLNode* notes) //------------------------------------------------------------ _Type curType = _AAny; - XMLNode& cur = *m; + XMLNode& cur = *m; // cur.getChild(0) must be "html", "body", or any XHTML // element that would be permitted within a "body" element . @@ -1257,7 +1235,7 @@ SBase::append(const XMLNode* notes) if (cname == "html") { - XMLNode& curHTML = cur.getChild(0); + XMLNode& curHTML = cur.getChild(0); // // checks the curHTML if the html tag contains "head" and "body" tags // which must be located in this order, otherwise nothing will be done. @@ -1297,14 +1275,14 @@ SBase::append(const XMLNode* notes) if (curType == _AHTML) { - XMLNode& curHTML = cur.getChild(0); - XMLNode& curBody = curHTML.getChild(1); + XMLNode& curHTML = cur.getChild(0); + XMLNode& curBody = curHTML.getChild(1); if (addedType == _AHTML) { // adds the given html tag to the current html tag - XMLNode& addedBody = added.getChild(1); + XMLNode& addedBody = added.getChild(1); for (i=0; i < addedBody.getNumChildren(); i++) { @@ -1332,9 +1310,9 @@ SBase::append(const XMLNode* notes) { // adds the given html tag to the current body tag - XMLNode addedHTML(added); - XMLNode& addedBody = addedHTML.getChild(1); - XMLNode& curBody = cur.getChild(0); + XMLNode addedHTML(added); + XMLNode& addedBody = addedHTML.getChild(1); + XMLNode& curBody = cur.getChild(0); for (i=0; i < curBody.getNumChildren(); i++) { @@ -1350,7 +1328,7 @@ SBase::append(const XMLNode* notes) // adds the given body or other tag (permitted in the body) to the current // body tag - XMLNode& curBody = cur.getChild(0); + XMLNode& curBody = cur.getChild(0); for (i=0; i < added.getNumChildren(); i++) { @@ -1366,8 +1344,8 @@ SBase::append(const XMLNode* notes) { // adds the given html tag to the current any tag permitted in the body. - XMLNode addedHTML(added); - XMLNode& addedBody = addedHTML.getChild(1); + XMLNode addedHTML(added); + XMLNode& addedBody = addedHTML.getChild(1); for (i=0; i < cur.getNumChildren(); i++) { @@ -1382,7 +1360,7 @@ SBase::append(const XMLNode* notes) { // adds the given body tag to the current any tag permitted in the body. - XMLNode addedBody(added); + XMLNode addedBody(added); for (i=0; i < cur.getNumChildren(); i++) { @@ -1430,16 +1408,16 @@ SBase::append(const std::string& notes) return LIBSBML_OPERATION_SUCCESS; } - XMLNode* notes_xmln; + XMLNode* notes_xmln; // you might not have a document !! if (getSBMLDocument() != NULL) { - XMLNamespaces* xmlns = getSBMLDocument()->getNamespaces(); - notes_xmln = XMLNode::convertStringToXMLNode(notes,xmlns); + XMLNamespaces* xmlns = getSBMLDocument()->getNamespaces(); + notes_xmln = XMLNode::convertStringToXMLNode(notes,xmlns); } else { - notes_xmln = XMLNode::convertStringToXMLNode(notes); + notes_xmln = XMLNode::convertStringToXMLNode(notes); } if(notes_xmln != NULL) @@ -1563,7 +1541,7 @@ SBase::getAncestorOfType(int type) const * @param xmlns the namespaces to set */ int -SBase::setNamespaces(XMLNamespaces* xmlns) +SBase::setNamespaces(XMLNamespaces* xmlns) { if (xmlns == NULL) { @@ -1635,7 +1613,7 @@ SBase::unset () int SBase::unset () { - XMLNode* empty = NULL; + XMLNode* empty = NULL; return set(empty); } @@ -1701,7 +1679,7 @@ bool SBase::hasValidLevelVersionNamespaceCombination() { int typecode = getTypeCode(); - XMLNamespaces *xmlns = getNamespaces(); + XMLNamespaces *xmlns = getNamespaces(); return hasValidLevelVersionNamespaceCombination(typecode, xmlns); } @@ -1799,7 +1777,7 @@ SBase::matchesCoreSBMLNamespace(const SBase * sb) const bool -SBase::hasValidLevelVersionNamespaceCombination(int typecode, XMLNamespaces *xmlns) +SBase::hasValidLevelVersionNamespaceCombination(int typecode, XMLNamespaces *xmlns) { @@ -1893,11 +1871,11 @@ char* SBase::toSBML () { ostringstream os; - XMLOutputStream stream(os, "UTF-8", false); + XMLOutputStream stream(os, "UTF-8", false); write(stream); - return safe_strdup( os.str().c_str() ); + return sbml_safe_strdup( os.str().c_str() ); } @@ -2097,11 +2075,11 @@ SBase::getObject(const std::string& objectName, unsigned int index) * Reads (initializes) this SBML_Lang object by reading from XMLInputStream. */ void -SBase::read (XMLInputStream& stream) +SBase::read (XMLInputStream& stream) { if ( !stream.peek().isStart() ) return; - const XMLToken element = stream.next(); + const XMLToken element = stream.next(); int position = 0; setSBaseFields( element ); @@ -2121,7 +2099,7 @@ SBase::read (XMLInputStream& stream) // need to check that any prefix on the sbmlns also occurs on element // remembering the horrible situation where the sbmlns might be declared // with more than one prefix - XMLNamespaces * xmlns = this->getSBMLNamespaces()->getNamespaces(); + XMLNamespaces * xmlns = this->getSBMLNamespaces()->getNamespaces(); if (xmlns != NULL) { int i = xmlns->getIndexByPrefix(element.getPrefix()); @@ -2178,7 +2156,7 @@ SBase::read (XMLInputStream& stream) checkDefaultNamespace(mSBMLNamespaces->getNamespaces(), element.getName()); if (!element.getPrefix().empty()) { - XMLNamespaces * prefixedNS = new XMLNamespaces(); + XMLNamespaces * prefixedNS = new XMLNamespaces(); prefixedNS->add(element.getURI(), element.getPrefix()); checkDefaultNamespace(prefixedNS, element.getName(), element.getPrefix()); delete prefixedNS; @@ -2199,7 +2177,7 @@ SBase::read (XMLInputStream& stream) } setElementText(text); - const XMLToken& next = stream.peek(); + const XMLToken& next = stream.peek(); // Re-check stream.isGood() because stream.peek() could hit something. if ( !stream.isGood() ) break; @@ -2254,7 +2232,7 @@ SBase::setElementText(const std::string &text) * Writes (serializes) this SBML_Lang object by writing it to XMLOutputStream. */ void -SBase::write (XMLOutputStream& stream) const +SBase::write (XMLOutputStream& stream) const { stream.startElement( getElementName(), getPrefix() ); @@ -2275,7 +2253,7 @@ SBase::write (XMLOutputStream& stream) const * implementation of this method as well. */ void -SBase::writeElements (XMLOutputStream& stream) const +SBase::writeElements (XMLOutputStream& stream) const { if ( m != NULL ) stream << *m; @@ -2293,7 +2271,7 @@ SBase::writeElements (XMLOutputStream& stream) const * XMLInputStream or @c NULL if the token was not recognized. */ SBase* -SBase::createObject (XMLInputStream& stream) +SBase::createObject (XMLInputStream& stream) { return NULL; } @@ -2310,7 +2288,7 @@ SBase::createObject (XMLInputStream& stream) * @return true if the subclass read from the stream, false otherwise. */ bool -SBase::readOtherXML (XMLInputStream& stream) +SBase::readOtherXML (XMLInputStream& stream) { bool read = false; return read; @@ -2323,7 +2301,7 @@ SBase::readOtherXML (XMLInputStream& stream) * @return true if read an element from the stream */ bool -SBase::read (XMLInputStream& stream) +SBase::read (XMLInputStream& stream) { const string& name = stream.peek().getName(); @@ -2340,7 +2318,7 @@ SBase::read (XMLInputStream& stream) } delete m; - m = new XMLNode(stream); + m = new XMLNode(stream); check(); return true; } @@ -2355,7 +2333,7 @@ SBase::read (XMLInputStream& stream) * @return true if read a element from the stream */ bool -SBase::read (XMLInputStream& stream) +SBase::read (XMLInputStream& stream) { const string& name = stream.peek().getName(); @@ -2371,13 +2349,13 @@ SBase::read (XMLInputStream& stream) } delete m; - m = new XMLNode(stream); + m = new XMLNode(stream); // // checks if the given default namespace (if any) is a valid // SBML_Lang namespace // - const XMLNamespaces &xmlns = m->getNamespaces(); + const XMLNamespaces &xmlns = m->getNamespaces(); checkDefaultNamespace(&xmlns,"notes"); return true; @@ -2546,10 +2524,10 @@ SBase::addExpectedAttributes(ExpectedAttributes& attributes) * parents implementation of this method as well. */ void -SBase::readAttributes (const XMLAttributes& attributes, - const ExpectedAttributes& expectedAttributes) +SBase::readAttributes (const XMLAttributes& attributes, + const ExpectedAttributes& expectedAttributes) { - const_cast<XMLAttributes&>(attributes).setErrorLog(getErrorLog()); + const_cast(attributes).setErrorLog(getErrorLog()); const unsigned int level = getLevel (); const unsigned int version = getVersion(); @@ -2601,15 +2579,6 @@ SBase::readAttributes (const XMLAttributes& attributes, logEmptyString("metaid", level, version, SBMLTypeCode_toString(getTypeCode())); } - - if (isSetMetaId()) - { - if (!SyntaxChecker::isValidXMLID(mMetaId)) - { - logError(SBMLInvalidMetaidSyntax, getLevel(), getVersion(), "The metaid '" + mMetaId + "' does not conform to the syntax."); - } - } - } @@ -2622,7 +2591,7 @@ SBase::getPrefix() const { std::string prefix = ""; - const XMLNamespaces *xmlns = getNamespaces(); + const XMLNamespaces *xmlns = getNamespaces(); string uri = getURI(); if(xmlns && mSBML) { @@ -2641,7 +2610,7 @@ SBase::getSBMLPrefix() const { std::string prefix = ""; - const XMLNamespaces *xmlns = getNamespaces(); + const XMLNamespaces *xmlns = getNamespaces(); if (xmlns == NULL) return getPrefix(); @@ -2686,7 +2655,7 @@ SBase::getRootElement() * of this method as well. */ void -SBase::writeAttributes (XMLOutputStream& stream) const +SBase::writeAttributes (XMLOutputStream& stream) const { string sbmlPrefix = getSBMLPrefix(); if ( !mMetaId.empty() ) @@ -2705,7 +2674,7 @@ SBase::writeAttributes (XMLOutputStream& stream) const * */ void -SBase::writeXMLNS (XMLOutputStream& stream) const +SBase::writeXMLNS (XMLOutputStream& stream) const { // do nothing. } @@ -2763,7 +2732,7 @@ int SBase::removeFromParentAndDelete() /** @cond doxygenLibsbmlInternal */ const std::string -SBase::checkMathMLNamespace(const XMLToken elem) +SBase::checkMathMLNamespace(const XMLToken elem) { std::string prefix = ""; unsigned int match = 0; @@ -2809,7 +2778,7 @@ SBase::checkMathMLNamespace(const XMLToken elem) /** @cond doxygenLibsbmlInternal */ void -SBase::checkDefaultNamespace(const XMLNamespaces* xmlns, +SBase::checkDefaultNamespace(const XMLNamespaces* xmlns, const std::string& elementName, const std::string& prefix) { @@ -2859,12 +2828,12 @@ SBase::check() // checks if the given default namespace (if any) is a valid // SBML_Lang namespace // - const XMLNamespaces &xmlns = m->getNamespaces(); + const XMLNamespaces &xmlns = m->getNamespaces(); checkDefaultNamespace(&xmlns,); while (nNodes < m->getNumChildren()) { - XMLNode topLevel = m->getChild(nNodes); + XMLNode topLevel = m->getChild(nNodes); // the top level must be an element (so it should be a start) if (topLevel.isStart() == false) @@ -2960,7 +2929,7 @@ SBase::check() * an sbml document, an error is logged. */ void -SBase::checkXHTML(const XMLNode * xhtml) +SBase::checkXHTML(const XMLNode * xhtml) { if (xhtml == NULL) return; @@ -2998,61 +2967,6 @@ SBase::checkXHTML(const XMLNode * xhtml) logError(errorDOC); } } - - XMLNamespaces* toplevelNS = (mSBML) ? mSBML->getNamespaces() : NULL; - - /* - * namespace declaration is variable - * if a whole html tag has been used - * or a whole body tag then namespace can be implicitly declared - */ - unsigned int children = xhtml->getNumChildren(); - - if (children > 1) - { - for (i=0; i < children; i++) - { - if (SyntaxChecker::isAllowedElement(xhtml->getChild(i))) - { - if (!SyntaxChecker::hasDeclaredNS(xhtml->getChild(i), - toplevelNS)) - { - logError(errorNS); - } - } - else - { - logError(errorELEM); - } - } - } - else - { - /* only one element which can be html or body with either implicit/explicit - * namespace declaration - * OR could be one of the listed elements. - */ - - const string& top_name = xhtml->getChild(0).getName(); - - if (top_name != "html" && top_name != "body" - && !SyntaxChecker::isAllowedElement(xhtml->getChild(0))) - { - logError(errorELEM); - } - else - { - if (!SyntaxChecker::hasDeclaredNS(xhtml->getChild(0), toplevelNS)) - { - logError(errorNS); - } - if (top_name == "html" - && !SyntaxChecker::isCorrectHTMLNode(xhtml->getChild(0))) - { - logError(errorELEM); - } - } - } } /** @endcond */ /** @cond doxygenLibsbmlInternal */ @@ -3107,14 +3021,14 @@ SBase::checkCompatibility(const SBase * object) const * roundtripping) declared on this SBML_Lang (XML) element. */ void -SBase::setSBaseFields (const XMLToken& element) +SBase::setSBaseFields (const XMLToken& element) { mLine = element.getLine (); mColumn = element.getColumn(); if (element.getNamespaces().getLength() > 0) { - XMLNamespaces tmpxmlns(element.getNamespaces()); + XMLNamespaces tmpxmlns(element.getNamespaces()); setNamespaces(&tmpxmlns); } else @@ -3217,7 +3131,7 @@ char* SBase_getString (SBase_t *sb) { return (sb != NULL && sb->isSet()) ? - safe_strdup(sb->getString().c_str()) : NULL; + sbml_safe_strdup(sb->getString().c_str()) : NULL; } @@ -3234,7 +3148,7 @@ char* SBase_getString (SBase_t *sb) { return (sb != NULL && sb->isSet()) ? - safe_strdup(sb->getString().c_str()) : NULL; + sbml_safe_strdup(sb->getString().c_str()) : NULL; } diff --git a/deviser/code_files/templates/SBase.h b/deviser/code_files/templates/SBase.h index 36e442ac8..48d7d800f 100644 --- a/deviser/code_files/templates/SBase.h +++ b/deviser/code_files/templates/SBase.h @@ -2,19 +2,14 @@ #define SBase_h -#include -#include - -#include - -#include +#include +#include +#include #include #include #include +#include -#include -#include -#include #include @@ -29,9 +24,6 @@ #include -LIBSBML_CPP_NAMESPACE_BEGIN - -class Model; class List; @@ -41,7 +33,6 @@ class XMLNamespaces; class XMLOutputStream; class XMLToken; -LIBSBML_CPP_NAMESPACE_END LIBSBML_CPP_NAMESPACE_BEGIN @@ -209,7 +200,7 @@ class LIBSBML_EXTERN SBase * @see unset() * @see SyntaxChecker::hasExpectedXHTMLSyntax(@if java XMLNode@endif) */ - XMLNode* get(); + XMLNode* get(); /** @@ -235,7 +226,7 @@ class LIBSBML_EXTERN SBase * @see unset() * @see SyntaxChecker::hasExpectedXHTMLSyntax(@if java XMLNode@endif) */ - const XMLNode* get() const; + const XMLNode* get() const; /** @@ -306,7 +297,7 @@ class LIBSBML_EXTERN SBase * @see append(const std::string& annotation) * @see unset() */ - XMLNode* get (); + XMLNode* get (); /** @@ -329,7 +320,7 @@ class LIBSBML_EXTERN SBase * @see append(const std::string& annotation) * @see unset() */ - const XMLNode* get () const; + const XMLNode* get () const; /** @@ -386,7 +377,7 @@ class LIBSBML_EXTERN SBase * @see getLevel() * @see getVersion() */ - virtual const XMLNamespaces* getNamespaces() const ; + virtual const XMLNamespaces* getNamespaces() const ; /** @@ -403,7 +394,7 @@ class LIBSBML_EXTERN SBase * @see getLevel() * @see getVersion() */ - virtual XMLNamespaces* getNamespaces(); + virtual XMLNamespaces* getNamespaces(); /** @@ -760,7 +751,7 @@ class LIBSBML_EXTERN SBase * @see append(const std::string& annotation) * @see unset() */ - virtual int set (XMLNode* annotation); + virtual int set (XMLNode* annotation); /** @@ -848,7 +839,7 @@ class LIBSBML_EXTERN SBase * @see append(const std::string& annotation) * @see unset() */ - virtual int append (const XMLNode* annotation); + virtual int append (const XMLNode* annotation); /** @@ -949,7 +940,7 @@ class LIBSBML_EXTERN SBase * @see removeTopLevelElement(const std::string elementName, const std::string elementURI) * @see replaceTopLevelElement(const std::string&) */ - int replaceTopLevelElement(const XMLNode* annotation); + int replaceTopLevelElement(const XMLNode* annotation); /** @@ -1023,7 +1014,7 @@ class LIBSBML_EXTERN SBase * @see unset() * @see SyntaxChecker::hasExpectedXHTMLSyntax(@if java XMLNode@endif) */ - int set(const XMLNode* notes); + int set(const XMLNode* notes); /** @@ -1120,7 +1111,7 @@ class LIBSBML_EXTERN SBase * @see unset() * @see SyntaxChecker::hasExpectedXHTMLSyntax(@if java XMLNode@endif) */ - int append(const XMLNode* notes); + int append(const XMLNode* notes); /** @@ -1231,7 +1222,7 @@ class LIBSBML_EXTERN SBase * @copydetails doc_returns_success_code * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} */ - int setNamespaces(XMLNamespaces* xmlns); + int setNamespaces(XMLNamespaces* xmlns); /** @@ -1530,7 +1521,7 @@ class LIBSBML_EXTERN SBase /** * Reads (initializes) this SBML_Lang object by reading from XMLInputStream. */ - void read (XMLInputStream& stream); + void read (XMLInputStream& stream); /** @endcond */ @@ -1538,7 +1529,7 @@ class LIBSBML_EXTERN SBase /** * Writes (serializes) this SBML_Lang object by writing it to XMLOutputStream. */ - virtual void write (XMLOutputStream& stream) const; + virtual void write (XMLOutputStream& stream) const; /** @endcond */ @@ -1554,7 +1545,7 @@ class LIBSBML_EXTERN SBase * ... * @endif@~ */ - virtual void writeElements (XMLOutputStream& stream) const; + virtual void writeElements (XMLOutputStream& stream) const; /** @endcond */ @@ -1772,7 +1763,7 @@ class LIBSBML_EXTERN SBase * @return the SBML_Lang object corresponding to next XMLToken in the * XMLInputStream or @c NULL if the token was not recognized. */ - virtual SBase* createObject (XMLInputStream& stream); + virtual SBase* createObject (XMLInputStream& stream); /** @@ -1789,7 +1780,7 @@ class LIBSBML_EXTERN SBase * @return @c true if the level, version and namespace values of this * SBML_Lang object correspond to a valid set of values, @c false otherwise. */ - bool hasValidLevelVersionNamespaceCombination(int typecode, XMLNamespaces *xmlns); + bool hasValidLevelVersionNamespaceCombination(int typecode, XMLNamespaces *xmlns); /** @@ -1798,7 +1789,7 @@ class LIBSBML_EXTERN SBase * * @return true if the subclass read from the stream, false otherwise. */ - virtual bool readOtherXML (XMLInputStream& stream); + virtual bool readOtherXML (XMLInputStream& stream); /** @@ -1868,8 +1859,8 @@ class LIBSBML_EXTERN SBase * XMLAttributes set into their specific fields. Be sure to call your * parents implementation of this method as well. */ - virtual void readAttributes (const XMLAttributes& attributes, - const ExpectedAttributes& expectedAttributes); + virtual void readAttributes (const XMLAttributes& attributes, + const ExpectedAttributes& expectedAttributes); /** @@ -1886,7 +1877,7 @@ class LIBSBML_EXTERN SBase * Be sure to implement wirteXMLNS() function to write xmlns attributes. * */ - virtual void writeAttributes (XMLOutputStream& stream) const; + virtual void writeAttributes (XMLOutputStream& stream) const; /** @@ -1895,7 +1886,7 @@ class LIBSBML_EXTERN SBase * (if any) to the XMLOutputStream. * */ - virtual void writeXMLNS (XMLOutputStream& stream) const; + virtual void writeXMLNS (XMLOutputStream& stream) const; /** @@ -1909,7 +1900,7 @@ class LIBSBML_EXTERN SBase * Checks that the given default namespace in the given element is valid. * If the given default namespace is not valid, an error is logged. */ - void checkDefaultNamespace(const XMLNamespaces* xmlns, + void checkDefaultNamespace(const XMLNamespaces* xmlns, const std::string& elementName, const std::string& prefix = ""); /** @@ -1924,13 +1915,13 @@ class LIBSBML_EXTERN SBase * If the xhtml does not conform to the specification of valid xhtml within * an sbml document, an error is logged. */ - void checkXHTML(const XMLNode *); + void checkXHTML(const XMLNode *); /** * Checks that the math ml ns has been declared */ - const std::string checkMathMLNamespace(const XMLToken elem); + const std::string checkMathMLNamespace(const XMLToken elem); /** * Sets the XML namespace to which this element belongs to. @@ -1984,8 +1975,8 @@ class LIBSBML_EXTERN SBase std::string mMetaId; std::string mId; - XMLNode* m; - XMLNode* m; + XMLNode* m; + XMLNode* m; SBMLDocument* mSBML; SBMLNamespaces* mSBMLNamespaces; void* mUserData; @@ -2026,7 +2017,7 @@ class LIBSBML_EXTERN SBase * Stores the location (line and column) and any XML namespaces (for * roundtripping) declared on this SBML_Lang (XML) element. */ - void setSBaseFields (const XMLToken& element); + void setSBaseFields (const XMLToken& element); /** @@ -2034,7 +2025,7 @@ class LIBSBML_EXTERN SBase * * @return true if read an element from the stream */ - bool read (XMLInputStream& stream); + bool read (XMLInputStream& stream); /** @@ -2042,7 +2033,7 @@ class LIBSBML_EXTERN SBase * * @return true if read a element from the stream */ - bool read (XMLInputStream& stream); + bool read (XMLInputStream& stream); /** @endcond */ @@ -2108,12 +2099,6 @@ SBase_getParentSBMLObject (SBase_t *sb); * Returns the ancestor SBase_t structure of the given SBase_t * structure that corresponds to the given type. * - * This function allows any structure to determine its exact - * location/function within a model. For example a - * StoichiometryMath_t structure has ancestors of type SpeciesReference_t, - * ListOf_t(Products/Reactants), Reaction_t, ListOfReactions_t and Model_t; - * any of which can be accessed via this function. - * * @param sb the SBase_t structure * @param type the typecode (int) of the structure to be returned * @@ -2522,20 +2507,6 @@ int SBase_unset (SBase_t *sb); -/** - * Returns the Model_t structure in which the given instance is located. - * - * @param sb the SBase_t structure - * - * @return the parent Model_t strucdture of the given structure. - * - * @memberof SBase_t - */ -LIBSBML_EXTERN -const Model_t * -SBase_getModel (const SBase_t *sb); - - /** * Returns the SBML_Lang Level of the overall SBML_Lang document. * diff --git a/deviser/code_files/templates/Writer.cpp b/deviser/code_files/templates/Writer.cpp index daaadf4eb..f4de1497b 100644 --- a/deviser/code_files/templates/Writer.cpp +++ b/deviser/code_files/templates/Writer.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include @@ -237,7 +237,7 @@ SBMLWriter::writeToString (const SBMLDocument* d) ostringstream stream; writeSBML(d, stream); - return safe_strdup( stream.str().c_str() ); + return sbml_safe_strdup( stream.str().c_str() ); } std::string diff --git a/deviser/code_files/templates/Writer.h b/deviser/code_files/templates/Writer.h index dbdeea2d9..4095513cc 100644 --- a/deviser/code_files/templates/Writer.h +++ b/deviser/code_files/templates/Writer.h @@ -2,8 +2,8 @@ #define SBMLWriter_h -#include -#include +#include +#include #ifdef __cplusplus diff --git a/deviser/code_files/templates/common.h b/deviser/code_files/templates/common.h index c3118b462..9ffe50d8d 100644 --- a/deviser/code_files/templates/common.h +++ b/deviser/code_files/templates/common.h @@ -2,7 +2,7 @@ #define LIBSBML_COMMON_H 1 -#include +#include #include @@ -74,11 +74,8 @@ static const int SBML_INT_MIN = -2147483647 - 1; #define LIBSBML_UNKNOWN_COLUMN SBML_INT_MAX -#include - -#include -#include - -#include +#include +#include +#include #endif /* LIBSBML_COMMON_H */ diff --git a/deviser/code_files/templates/lib-namespace.h.cmake b/deviser/code_files/templates/lib-namespace.h.cmake index f1bb23ff9..ff79fd4f3 100644 --- a/deviser/code_files/templates/lib-namespace.h.cmake +++ b/deviser/code_files/templates/lib-namespace.h.cmake @@ -7,14 +7,6 @@ #ifndef LIBSBML_NAMESPACE_H #define LIBSBML_NAMESPACE_H 1 - -#ifndef SWIG -#include - -LIBSBML_CPP_NAMESPACE_USE - -#endif - /* * * The idea of the following marcors are borrowed from diff --git a/deviser/pytest_files/functions.py b/deviser/pytest_files/functions.py index 512e23491..bcc4440a6 100644 --- a/deviser/pytest_files/functions.py +++ b/deviser/pytest_files/functions.py @@ -102,8 +102,8 @@ def compare_files(infile, outfile, fails, not_tested): else: fails.append(infile) print('{0}=================>> FAILED'.format(outfile)) - print('\n\nEXPECTED:\n{0}'.format(indata.strip())) - print('=================\n\nGOT:\n{0}'.format(out.strip())) +# print('\n\nEXPECTED:\n{0}'.format(indata.strip())) +# print('=================\n\nGOT:\n{0}'.format(out.strip())) print('=================') ret = 1 return ret diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/LICENSE.txt b/deviser/pytest_files/test_other_library/test-code/tsb/LICENSE.txt new file mode 100644 index 000000000..b2398099d --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/LICENSE.txt @@ -0,0 +1,2 @@ +LICENSE + diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/README.md b/deviser/pytest_files/test_other_library/test-code/tsb/README.md new file mode 100644 index 000000000..883843cca --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/README.md @@ -0,0 +1,38 @@ +# LibTSB + +## Dependencies +This library requires either liblx or libSBML to be present, as its XML parsing layer will be used. For that either expat, xerces-c or libXML2 needs to be available. + +## Building +This library uses [CMake](http://cmake.org) to build the library, so from an initial checkout all you would need to do is to run: + + + mkdir build + cd build + cmake -DLIBSBML_LIBRARY=< path to libsbml lib> -DLIBSBML_INCLUDE_DIR=< path to includes > ... -DEXTRA_LIBS= < comma separated list of xml libraries> + make + make install + +OR + + + mkdir build + cd build + cmake -DLIBLX_LIBRARY=< path to liblx lib> -DLIBLX_INCLUDE_DIR=< path to includes > ... -DEXTRA_LIBS= < comma separated list of xml libraries> + make + make install + + + +Should libSBML/liblx be installed in a default location it will be found automatically. Note that you do need to list the xml libraries that libSBML was linked against. In most cases libSBML is compiled against libXML and have compression enabled, so your `EXTRA_LIBS` would be: + + EXTRA_LIBS=xml2;bz2;z;iconv + +note the semicolon denoting the listing of several libraries. Of course you could also enter the full path to each individual file, just to give an example, on windows I use: + + EXTRA_LIBS=D:/dependencies/lib/expat.lib + +for linking against `expat` and indicating, that libSBML/liblx was compiled without compression. + +## License +This project is open source and freely available under \ No newline at end of file diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/TSBBase.cpp b/deviser/pytest_files/test_other_library/test-code/tsb/TSBBase.cpp index a1d44c79c..479ade35e 100644 --- a/deviser/pytest_files/test_other_library/test-code/tsb/TSBBase.cpp +++ b/deviser/pytest_files/test_other_library/test-code/tsb/TSBBase.cpp @@ -183,12 +183,12 @@ TSBBase::TSBBase(const TSBBase& orig) , mURI(orig.mURI) { if(orig.mNotes != NULL) - this->mNotes = new XMLNode(*const_cast(orig).getNotes()); + this->mNotes = new XMLNode(*const_cast(orig).getNotes()); else this->mNotes = NULL; if(orig.mTestAnnotation != NULL) - this->mTestAnnotation = new XMLNode(*const_cast(orig).mTestAnnotation); + this->mTestAnnotation = new XMLNode(*const_cast(orig).mTestAnnotation); else this->mTestAnnotation = NULL; @@ -226,14 +226,14 @@ TSBBase& TSBBase::operator=(const TSBBase& rhs) delete this->mNotes; if(rhs.mNotes != NULL) - this->mNotes = new XMLNode(*const_cast(rhs).getNotes()); + this->mNotes = new XMLNode(*const_cast(rhs).getNotes()); else this->mNotes = NULL; delete this->mTestAnnotation; if(rhs.mTestAnnotation != NULL) - this->mTestAnnotation = new XMLNode(*const_cast(rhs).mTestAnnotation); + this->mTestAnnotation = new XMLNode(*const_cast(rhs).mTestAnnotation); else this->mTestAnnotation = NULL; @@ -289,14 +289,14 @@ TSBBase::getId() const /* * @return the notes of this TSB object. */ - XMLNode* +XMLNode* TSBBase::getNotes() { return mNotes; } -const XMLNode* +const XMLNode* TSBBase::getNotes() const { return mNotes; @@ -309,28 +309,28 @@ TSBBase::getNotes() const std::string TSBBase::getNotesString() { - return XMLNode::convertXMLNodeToString(mNotes); + return XMLNode::convertXMLNodeToString(mNotes); } std::string TSBBase::getNotesString() const { - return XMLNode::convertXMLNodeToString(mNotes); + return XMLNode::convertXMLNodeToString(mNotes); } /* * @return the annotation of this TSB object. */ - XMLNode* +XMLNode* TSBBase::getTestAnnotation () { return mTestAnnotation; } -const XMLNode* +const XMLNode* TSBBase::getTestAnnotation () const { return const_cast(this)->getTestAnnotation(); @@ -343,14 +343,14 @@ TSBBase::getTestAnnotation () const std::string TSBBase::getTestAnnotationString () { - return XMLNode::convertXMLNodeToString(getTestAnnotation()); + return XMLNode::convertXMLNodeToString(getTestAnnotation()); } std::string TSBBase::getTestAnnotationString () const { - return XMLNode::convertXMLNodeToString(getTestAnnotation()); + return XMLNode::convertXMLNodeToString(getTestAnnotation()); } @@ -428,7 +428,7 @@ TSBBase::unsetUserData() /* * @return the Namespaces associated with this TSB object */ - XMLNamespaces* +XMLNamespaces* TSBBase::getNamespaces() { if (mTSB != NULL) @@ -438,7 +438,7 @@ TSBBase::getNamespaces() } -const XMLNamespaces* +const XMLNamespaces* TSBBase::getNamespaces() const { if (mTSB != NULL) @@ -662,7 +662,7 @@ TSBBase::setId (const std::string& sid) * Sets the annotation of this TSB object to a copy of annotation. */ int -TSBBase::setTestAnnotation ( XMLNode* annotation) +TSBBase::setTestAnnotation (XMLNode* annotation) { if (annotation == NULL) { @@ -695,17 +695,17 @@ TSBBase::setTestAnnotation (const std::string& annotation) return LIBTSB_OPERATION_SUCCESS; } - XMLNode* annt_xmln; + XMLNode* annt_xmln; // you might not have a document !! if (getTSBDocument() != NULL) { - XMLNamespaces* xmlns = getTSBDocument()->getNamespaces(); - annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); + XMLNamespaces* xmlns = getTSBDocument()->getNamespaces(); + annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); } else { - annt_xmln = XMLNode::convertStringToXMLNode(annotation); + annt_xmln = XMLNode::convertStringToXMLNode(annotation); } if(annt_xmln != NULL) @@ -723,7 +723,7 @@ TSBBase::setTestAnnotation (const std::string& annotation) * adding additional information. */ int -TSBBase::appendTestAnnotation (const XMLNode* annotation) +TSBBase::appendTestAnnotation (const XMLNode* annotation) { int success = LIBTSB_OPERATION_FAILED; unsigned int duplicates = 0; @@ -731,14 +731,14 @@ TSBBase::appendTestAnnotation (const XMLNode* annotation) if(annotation == NULL) return LIBTSB_OPERATION_SUCCESS; - XMLNode* new_annotation = NULL; + XMLNode* new_annotation = NULL; const string& name = annotation->getName(); // check for annotation tags and add if necessary if (name != "testAnnotation") { - XMLToken ann_t = XMLToken( XMLTriple("testAnnotation", "", ""), XMLAttributes()); - new_annotation = new XMLNode(ann_t); + XMLToken ann_t = XMLToken(XMLTriple("testAnnotation", "", ""), XMLAttributes()); + new_annotation = new XMLNode(ann_t); new_annotation->addChild(*annotation); } else @@ -787,7 +787,7 @@ TSBBase::appendTestAnnotation (const XMLNode* annotation) } else { - XMLNode *copy = mTestAnnotation->clone(); + XMLNode *copy = mTestAnnotation->clone(); success = setTestAnnotation(copy); delete copy; } @@ -813,15 +813,15 @@ int TSBBase::appendTestAnnotation (const std::string& annotation) { int success = LIBTSB_OPERATION_FAILED; - XMLNode* annt_xmln; + XMLNode* annt_xmln; if (getTSBDocument() != NULL) { - XMLNamespaces* xmlns = getTSBDocument()->getNamespaces(); - annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); + XMLNamespaces* xmlns = getTSBDocument()->getNamespaces(); + annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); } else { - annt_xmln = XMLNode::convertStringToXMLNode(annotation); + annt_xmln = XMLNode::convertStringToXMLNode(annotation); } if(annt_xmln != NULL) @@ -858,7 +858,7 @@ TSBBase::removeTopLevelTestAnnotationElement(const std::string elementName, // check uri matches if (elementURI.empty() == false) { - XMLNode child = mTestAnnotation->getChild(index); + XMLNode child = mTestAnnotation->getChild(index); std::string prefix = child.getPrefix(); if (prefix.empty() == false @@ -910,10 +910,10 @@ TSBBase::removeTopLevelTestAnnotationElement(const std::string elementName, int -TSBBase::replaceTopLevelTestAnnotationElement(const XMLNode* annotation) +TSBBase::replaceTopLevelTestAnnotationElement(const XMLNode* annotation) { int success = LIBTSB_OPERATION_FAILED; - XMLNode * replacement = NULL; + XMLNode * replacement = NULL; if (annotation->getName() == "testAnnotation") { if (annotation->getNumChildren() != 1) @@ -947,15 +947,15 @@ int TSBBase::replaceTopLevelTestAnnotationElement(const std::string& annotation) { int success = LIBTSB_OPERATION_FAILED; - XMLNode* annt_xmln; + XMLNode* annt_xmln; if (getTSBDocument() != NULL) { - XMLNamespaces* xmlns = getTSBDocument()->getNamespaces(); - annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); + XMLNamespaces* xmlns = getTSBDocument()->getNamespaces(); + annt_xmln = XMLNode::convertStringToXMLNode(annotation,xmlns); } else { - annt_xmln = XMLNode::convertStringToXMLNode(annotation); + annt_xmln = XMLNode::convertStringToXMLNode(annotation); } if(annt_xmln != NULL) @@ -973,7 +973,7 @@ TSBBase::replaceTopLevelTestAnnotationElement(const std::string& annotation) * Sets the notes of this TSB object to a copy of notes. */ int -TSBBase::setNotes(const XMLNode* notes) +TSBBase::setNotes(const XMLNode* notes) { if (mNotes == notes) { @@ -993,13 +993,13 @@ TSBBase::setNotes(const XMLNode* notes) if (name == "notes") { - mNotes = static_cast< XMLNode*>( notes->clone() ); + mNotes = static_cast( notes->clone() ); } else { - XMLToken notes_t = XMLToken( XMLTriple("notes", "", ""), - XMLAttributes()); - mNotes = new XMLNode(notes_t); + XMLToken notes_t = XMLToken(XMLTriple("notes", "", ""), + XMLAttributes()); + mNotes = new XMLNode(notes_t); // The root node of the given XMLNode tree can be an empty XMLNode // (i.e. neither start, end, nor text XMLNode) if the given notes was @@ -1041,17 +1041,17 @@ TSBBase::setNotes(const std::string& notes, bool addXHTMLMarkup) } else { - XMLNode* notes_xmln; + XMLNode* notes_xmln; // you might not have a document !! if (getTSBDocument() != NULL) { - XMLNamespaces* xmlns = getTSBDocument()->getNamespaces(); - notes_xmln = XMLNode::convertStringToXMLNode(notes,xmlns); + XMLNamespaces* xmlns = getTSBDocument()->getNamespaces(); + notes_xmln = XMLNode::convertStringToXMLNode(notes,xmlns); } else { - notes_xmln = XMLNode::convertStringToXMLNode(notes); + notes_xmln = XMLNode::convertStringToXMLNode(notes); } if (notes_xmln != NULL) @@ -1064,11 +1064,11 @@ TSBBase::setNotes(const std::string& notes, bool addXHTMLMarkup) && notes_xmln->isText() == true) { //create a parent node of xhtml type p - XMLAttributes blank_att = XMLAttributes(); - XMLTriple triple = XMLTriple("p", "http://www.w3.org/1999/xhtml", ""); - XMLNamespaces xmlns = XMLNamespaces(); + XMLAttributes blank_att = XMLAttributes(); + XMLTriple triple = XMLTriple("p", "http://www.w3.org/1999/xhtml", ""); + XMLNamespaces xmlns = XMLNamespaces(); xmlns.add("http://www.w3.org/1999/xhtml", ""); - XMLNode *xmlnode = new XMLNode( XMLToken(triple, blank_att, xmlns)); + XMLNode *xmlnode = new XMLNode(XMLToken(triple, blank_att, xmlns)); // create a text node from the text given xmlnode->addChild(*notes_xmln); @@ -1098,7 +1098,7 @@ TSBBase::setNotes(const std::string& notes, bool addXHTMLMarkup) * adding additional information. */ int -TSBBase::appendNotes(const XMLNode* notes) +TSBBase::appendNotes(const XMLNode* notes) { int success = LIBTSB_OPERATION_FAILED; if(notes == NULL) @@ -1127,7 +1127,7 @@ TSBBase::appendNotes(const XMLNode* notes) typedef enum { _ANotesHTML, _ANotesBody, _ANotesAny } _NotesType; _NotesType addedNotesType = _ANotesAny; - XMLNode addedNotes; + XMLNode addedNotes; //------------------------------------------------------------ // @@ -1238,7 +1238,7 @@ TSBBase::appendNotes(const XMLNode* notes) if (getLevel() > 2 || (getLevel() == 2 && getVersion() > 1)) { - XMLNode tmpNotes( XMLTriple("notes","",""), XMLAttributes()); + XMLNode tmpNotes(XMLTriple("notes","",""), XMLAttributes()); if (addedNotesType == _ANotesAny) { @@ -1251,10 +1251,9 @@ TSBBase::appendNotes(const XMLNode* notes) { tmpNotes.addChild(addedNotes); } - } - + } - if ( mNotes != NULL ) + if (mNotes != NULL) { //------------------------------------------------------------ // @@ -1263,7 +1262,7 @@ TSBBase::appendNotes(const XMLNode* notes) //------------------------------------------------------------ _NotesType curNotesType = _ANotesAny; - XMLNode& curNotes = *mNotes; + XMLNode& curNotes = *mNotes; // curNotes.getChild(0) must be "html", "body", or any XHTML // element that would be permitted within a "body" element . @@ -1272,7 +1271,7 @@ TSBBase::appendNotes(const XMLNode* notes) if (cname == "html") { - XMLNode& curHTML = curNotes.getChild(0); + XMLNode& curHTML = curNotes.getChild(0); // // checks the curHTML if the html tag contains "head" and "body" tags // which must be located in this order, otherwise nothing will be done. @@ -1312,14 +1311,14 @@ TSBBase::appendNotes(const XMLNode* notes) if (curNotesType == _ANotesHTML) { - XMLNode& curHTML = curNotes.getChild(0); - XMLNode& curBody = curHTML.getChild(1); + XMLNode& curHTML = curNotes.getChild(0); + XMLNode& curBody = curHTML.getChild(1); if (addedNotesType == _ANotesHTML) { // adds the given html tag to the current html tag - XMLNode& addedBody = addedNotes.getChild(1); + XMLNode& addedBody = addedNotes.getChild(1); for (i=0; i < addedBody.getNumChildren(); i++) { @@ -1347,9 +1346,9 @@ TSBBase::appendNotes(const XMLNode* notes) { // adds the given html tag to the current body tag - XMLNode addedHTML(addedNotes); - XMLNode& addedBody = addedHTML.getChild(1); - XMLNode& curBody = curNotes.getChild(0); + XMLNode addedHTML(addedNotes); + XMLNode& addedBody = addedHTML.getChild(1); + XMLNode& curBody = curNotes.getChild(0); for (i=0; i < curBody.getNumChildren(); i++) { @@ -1365,7 +1364,7 @@ TSBBase::appendNotes(const XMLNode* notes) // adds the given body or other tag (permitted in the body) to the current // body tag - XMLNode& curBody = curNotes.getChild(0); + XMLNode& curBody = curNotes.getChild(0); for (i=0; i < addedNotes.getNumChildren(); i++) { @@ -1381,8 +1380,8 @@ TSBBase::appendNotes(const XMLNode* notes) { // adds the given html tag to the current any tag permitted in the body. - XMLNode addedHTML(addedNotes); - XMLNode& addedBody = addedHTML.getChild(1); + XMLNode addedHTML(addedNotes); + XMLNode& addedBody = addedHTML.getChild(1); for (i=0; i < curNotes.getNumChildren(); i++) { @@ -1397,7 +1396,7 @@ TSBBase::appendNotes(const XMLNode* notes) { // adds the given body tag to the current any tag permitted in the body. - XMLNode addedBody(addedNotes); + XMLNode addedBody(addedNotes); for (i=0; i < curNotes.getNumChildren(); i++) { @@ -1445,16 +1444,16 @@ TSBBase::appendNotes(const std::string& notes) return LIBTSB_OPERATION_SUCCESS; } - XMLNode* notes_xmln; + XMLNode* notes_xmln; // you might not have a document !! if (getTSBDocument() != NULL) { - XMLNamespaces* xmlns = getTSBDocument()->getNamespaces(); - notes_xmln = XMLNode::convertStringToXMLNode(notes,xmlns); + XMLNamespaces* xmlns = getTSBDocument()->getNamespaces(); + notes_xmln = XMLNode::convertStringToXMLNode(notes,xmlns); } else { - notes_xmln = XMLNode::convertStringToXMLNode(notes); + notes_xmln = XMLNode::convertStringToXMLNode(notes); } if(notes_xmln != NULL) @@ -1578,7 +1577,7 @@ TSBBase::getAncestorOfType(int type) const * @param xmlns the namespaces to set */ int -TSBBase::setNamespaces( XMLNamespaces* xmlns) +TSBBase::setNamespaces(XMLNamespaces* xmlns) { if (xmlns == NULL) { @@ -1650,7 +1649,7 @@ TSBBase::unsetNotes () int TSBBase::unsetTestAnnotation () { - XMLNode* empty = NULL; + XMLNode* empty = NULL; return setTestAnnotation(empty); } @@ -1708,7 +1707,7 @@ bool TSBBase::hasValidLevelVersionNamespaceCombination() { int typecode = getTypeCode(); - XMLNamespaces *xmlns = getNamespaces(); + XMLNamespaces *xmlns = getNamespaces(); return hasValidLevelVersionNamespaceCombination(typecode, xmlns); } @@ -1806,7 +1805,7 @@ TSBBase::matchesCoreTSBNamespace(const TSBBase * sb) const bool -TSBBase::hasValidLevelVersionNamespaceCombination(int typecode, XMLNamespaces *xmlns) +TSBBase::hasValidLevelVersionNamespaceCombination(int typecode, XMLNamespaces *xmlns) { @@ -1900,7 +1899,7 @@ char* TSBBase::toTSB () { ostringstream os; - XMLOutputStream stream(os, "UTF-8", false); + XMLOutputStream stream(os, "UTF-8", false); write(stream); @@ -2104,11 +2103,11 @@ TSBBase::getObject(const std::string& objectName, unsigned int index) * Reads (initializes) this TSB object by reading from XMLInputStream. */ void -TSBBase::read ( XMLInputStream& stream) +TSBBase::read (XMLInputStream& stream) { if ( !stream.peek().isStart() ) return; - const XMLToken element = stream.next(); + const XMLToken element = stream.next(); int position = 0; setTSBBaseFields( element ); @@ -2128,7 +2127,7 @@ TSBBase::read ( XMLInputStream& stream) // need to check that any prefix on the tsbns also occurs on element // remembering the horrible situation where the tsbns might be declared // with more than one prefix - XMLNamespaces * xmlns = this->getTSBNamespaces()->getNamespaces(); + XMLNamespaces * xmlns = this->getTSBNamespaces()->getNamespaces(); if (xmlns != NULL) { int i = xmlns->getIndexByPrefix(element.getPrefix()); @@ -2188,7 +2187,7 @@ TSBBase::read ( XMLInputStream& stream) checkDefaultNamespace(mTSBNamespaces->getNamespaces(), element.getName()); if (!element.getPrefix().empty()) { - XMLNamespaces * prefixedNS = new XMLNamespaces(); + XMLNamespaces * prefixedNS = new XMLNamespaces(); prefixedNS->add(element.getURI(), element.getPrefix()); checkDefaultNamespace(prefixedNS, element.getName(), element.getPrefix()); delete prefixedNS; @@ -2209,7 +2208,7 @@ TSBBase::read ( XMLInputStream& stream) } setElementText(text); - const XMLToken& next = stream.peek(); + const XMLToken& next = stream.peek(); // Re-check stream.isGood() because stream.peek() could hit something. if ( !stream.isGood() ) break; @@ -2264,7 +2263,7 @@ TSBBase::setElementText(const std::string &text) * Writes (serializes) this TSB object by writing it to XMLOutputStream. */ void -TSBBase::write ( XMLOutputStream& stream) const +TSBBase::write (XMLOutputStream& stream) const { stream.startElement( getElementName(), getPrefix() ); @@ -2285,7 +2284,7 @@ TSBBase::write ( XMLOutputStream& stream) const * implementation of this method as well. */ void -TSBBase::writeElements ( XMLOutputStream& stream) const +TSBBase::writeElements (XMLOutputStream& stream) const { if ( mNotes != NULL ) stream << *mNotes; @@ -2303,7 +2302,7 @@ TSBBase::writeElements ( XMLOutputStream& stream) const * XMLInputStream or @c NULL if the token was not recognized. */ TSBBase* -TSBBase::createObject ( XMLInputStream& stream) +TSBBase::createObject (XMLInputStream& stream) { return NULL; } @@ -2320,7 +2319,7 @@ TSBBase::createObject ( XMLInputStream& stream) * @return true if the subclass read from the stream, false otherwise. */ bool -TSBBase::readOtherXML ( XMLInputStream& stream) +TSBBase::readOtherXML (XMLInputStream& stream) { bool read = false; return read; @@ -2333,7 +2332,7 @@ TSBBase::readOtherXML ( XMLInputStream& stream) * @return true if read an element from the stream */ bool -TSBBase::readTestAnnotation ( XMLInputStream& stream) +TSBBase::readTestAnnotation (XMLInputStream& stream) { const string& name = stream.peek().getName(); @@ -2350,7 +2349,7 @@ TSBBase::readTestAnnotation ( XMLInputStream& stream) } delete mTestAnnotation; - mTestAnnotation = new XMLNode(stream); + mTestAnnotation = new XMLNode(stream); checkTestAnnotation(); return true; } @@ -2365,7 +2364,7 @@ TSBBase::readTestAnnotation ( XMLInputStream& stream) * @return true if read a element from the stream */ bool -TSBBase::readNotes ( XMLInputStream& stream) +TSBBase::readNotes (XMLInputStream& stream) { const string& name = stream.peek().getName(); @@ -2381,13 +2380,13 @@ TSBBase::readNotes ( XMLInputStream& stream) } delete mNotes; - mNotes = new XMLNode(stream); + mNotes = new XMLNode(stream); // // checks if the given default namespace (if any) is a valid // TSB namespace // - const XMLNamespaces &xmlns = mNotes->getNamespaces(); + const XMLNamespaces &xmlns = mNotes->getNamespaces(); checkDefaultNamespace(&xmlns,"notes"); return true; @@ -2556,10 +2555,10 @@ TSBBase::addExpectedAttributes(ExpectedAttributes& attributes) * parents implementation of this method as well. */ void -TSBBase::readAttributes (const XMLAttributes& attributes, - const ExpectedAttributes& expectedAttributes) +TSBBase::readAttributes (const XMLAttributes& attributes, + const ExpectedAttributes& expectedAttributes) { - const_cast< XMLAttributes&>(attributes).setErrorLog(getErrorLog()); + const_cast(attributes).setErrorLog(getErrorLog()); const unsigned int level = getLevel (); const unsigned int version = getVersion(); @@ -2623,7 +2622,7 @@ TSBBase::getPrefix() const { std::string prefix = ""; - const XMLNamespaces *xmlns = getNamespaces(); + const XMLNamespaces *xmlns = getNamespaces(); string uri = getURI(); if(xmlns && mTSB) { @@ -2642,7 +2641,7 @@ TSBBase::getTSBPrefix() const { std::string prefix = ""; - const XMLNamespaces *xmlns = getNamespaces(); + const XMLNamespaces *xmlns = getNamespaces(); if (xmlns == NULL) return getPrefix(); @@ -2687,7 +2686,7 @@ TSBBase::getRootElement() * of this method as well. */ void -TSBBase::writeAttributes ( XMLOutputStream& stream) const +TSBBase::writeAttributes (XMLOutputStream& stream) const { string tsbPrefix = getTSBPrefix(); if ( !mMetaId.empty() ) @@ -2706,7 +2705,7 @@ TSBBase::writeAttributes ( XMLOutputStream& stream) const * */ void -TSBBase::writeXMLNS ( XMLOutputStream& stream) const +TSBBase::writeXMLNS (XMLOutputStream& stream) const { // do nothing. } @@ -2764,7 +2763,7 @@ int TSBBase::removeFromParentAndDelete() /** @cond doxygenLibtsbInternal */ const std::string -TSBBase::checkMathMLNamespace(const XMLToken elem) +TSBBase::checkMathMLNamespace(const XMLToken elem) { std::string prefix = ""; unsigned int match = 0; @@ -2810,7 +2809,7 @@ TSBBase::checkMathMLNamespace(const XMLToken elem) /** @cond doxygenLibtsbInternal */ void -TSBBase::checkDefaultNamespace(const XMLNamespaces* xmlns, +TSBBase::checkDefaultNamespace(const XMLNamespaces* xmlns, const std::string& elementName, const std::string& prefix) { @@ -2860,12 +2859,12 @@ TSBBase::checkTestAnnotation() // checks if the given default namespace (if any) is a valid // TSB namespace // - const XMLNamespaces &xmlns = mTestAnnotation->getNamespaces(); + const XMLNamespaces &xmlns = mTestAnnotation->getNamespaces(); checkDefaultNamespace(&xmlns,"testAnnotation"); while (nNodes < mTestAnnotation->getNumChildren()) { - XMLNode topLevel = mTestAnnotation->getChild(nNodes); + XMLNode topLevel = mTestAnnotation->getChild(nNodes); // the top level must be an element (so it should be a start) if (topLevel.isStart() == false) @@ -2961,7 +2960,7 @@ TSBBase::checkTestAnnotation() * an tsb document, an error is logged. */ void -TSBBase::checkXHTML(const XMLNode * xhtml) +TSBBase::checkXHTML(const XMLNode * xhtml) { if (xhtml == NULL) return; @@ -2999,7 +2998,6 @@ TSBBase::checkXHTML(const XMLNode * xhtml) logError(errorDOC); } } - } /** @endcond */ /** @cond doxygenLibtsbInternal */ @@ -3054,14 +3052,14 @@ TSBBase::checkCompatibility(const TSBBase * object) const * roundtripping) declared on this TSB (XML) element. */ void -TSBBase::setTSBBaseFields (const XMLToken& element) +TSBBase::setTSBBaseFields (const XMLToken& element) { mLine = element.getLine (); mColumn = element.getColumn(); if (element.getNamespaces().getLength() > 0) { - XMLNamespaces tmpxmlns(element.getNamespaces()); + XMLNamespaces tmpxmlns(element.getNamespaces()); setNamespaces(&tmpxmlns); } else diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/TSBBase.h b/deviser/pytest_files/test_other_library/test-code/tsb/TSBBase.h index 4874ccd97..9ec8cc567 100644 --- a/deviser/pytest_files/test_other_library/test-code/tsb/TSBBase.h +++ b/deviser/pytest_files/test_other_library/test-code/tsb/TSBBase.h @@ -62,7 +62,6 @@ #include #include -class Model; class List; @@ -72,6 +71,7 @@ class XMLNamespaces; class XMLOutputStream; class XMLToken; + LIBTSB_CPP_NAMESPACE_BEGIN class TSBDocument; @@ -263,7 +263,7 @@ class LIBTSB_EXTERN TSBBase * @see unsetNotes() * @see SyntaxChecker::hasExpectedXHTMLSyntax(@if java XMLNode@endif) */ - const XMLNode* getNotes() const; + const XMLNode* getNotes() const; /** @@ -357,7 +357,7 @@ class LIBTSB_EXTERN TSBBase * @see appendTestAnnotation(const std::string& annotation) * @see unsetTestAnnotation() */ - const XMLNode* getTestAnnotation () const; + const XMLNode* getTestAnnotation () const; /** @@ -414,7 +414,7 @@ class LIBTSB_EXTERN TSBBase * @see getLevel() * @see getVersion() */ - virtual const XMLNamespaces* getNamespaces() const ; + virtual const XMLNamespaces* getNamespaces() const ; /** @@ -431,7 +431,7 @@ class LIBTSB_EXTERN TSBBase * @see getLevel() * @see getVersion() */ - virtual XMLNamespaces* getNamespaces(); + virtual XMLNamespaces* getNamespaces(); /** @@ -788,7 +788,7 @@ class LIBTSB_EXTERN TSBBase * @see appendTestAnnotation(const std::string& annotation) * @see unsetTestAnnotation() */ - virtual int setTestAnnotation ( XMLNode* annotation); + virtual int setTestAnnotation (XMLNode* annotation); /** @@ -876,7 +876,7 @@ class LIBTSB_EXTERN TSBBase * @see appendTestAnnotation(const std::string& annotation) * @see unsetTestAnnotation() */ - virtual int appendTestAnnotation (const XMLNode* annotation); + virtual int appendTestAnnotation (const XMLNode* annotation); /** @@ -977,7 +977,7 @@ class LIBTSB_EXTERN TSBBase * @see removeTopLevelTestAnnotationElement(const std::string elementName, const std::string elementURI) * @see replaceTopLevelTestAnnotationElement(const std::string&) */ - int replaceTopLevelTestAnnotationElement(const XMLNode* annotation); + int replaceTopLevelTestAnnotationElement(const XMLNode* annotation); /** @@ -1051,7 +1051,7 @@ class LIBTSB_EXTERN TSBBase * @see unsetNotes() * @see SyntaxChecker::hasExpectedXHTMLSyntax(@if java XMLNode@endif) */ - int setNotes(const XMLNode* notes); + int setNotes(const XMLNode* notes); /** @@ -1148,7 +1148,7 @@ class LIBTSB_EXTERN TSBBase * @see unsetNotes() * @see SyntaxChecker::hasExpectedXHTMLSyntax(@if java XMLNode@endif) */ - int appendNotes(const XMLNode* notes); + int appendNotes(const XMLNode* notes); /** @@ -1259,7 +1259,7 @@ class LIBTSB_EXTERN TSBBase * @copydetails doc_returns_success_code * @li @tsbconstant{LIBTSB_OPERATION_SUCCESS, OperationReturnValues_t} */ - int setNamespaces( XMLNamespaces* xmlns); + int setNamespaces(XMLNamespaces* xmlns); /** @@ -1558,7 +1558,7 @@ class LIBTSB_EXTERN TSBBase /** * Reads (initializes) this TSB object by reading from XMLInputStream. */ - void read ( XMLInputStream& stream); + void read (XMLInputStream& stream); /** @endcond */ @@ -1566,7 +1566,7 @@ class LIBTSB_EXTERN TSBBase /** * Writes (serializes) this TSB object by writing it to XMLOutputStream. */ - virtual void write ( XMLOutputStream& stream) const; + virtual void write (XMLOutputStream& stream) const; /** @endcond */ @@ -1582,7 +1582,7 @@ class LIBTSB_EXTERN TSBBase * ... * @endif@~ */ - virtual void writeElements ( XMLOutputStream& stream) const; + virtual void writeElements (XMLOutputStream& stream) const; /** @endcond */ @@ -1800,7 +1800,7 @@ class LIBTSB_EXTERN TSBBase * @return the TSB object corresponding to next XMLToken in the * XMLInputStream or @c NULL if the token was not recognized. */ - virtual TSBBase* createObject ( XMLInputStream& stream); + virtual TSBBase* createObject (XMLInputStream& stream); /** @@ -1817,7 +1817,7 @@ class LIBTSB_EXTERN TSBBase * @return @c true if the level, version and namespace values of this * TSB object correspond to a valid set of values, @c false otherwise. */ - bool hasValidLevelVersionNamespaceCombination(int typecode, XMLNamespaces *xmlns); + bool hasValidLevelVersionNamespaceCombination(int typecode, XMLNamespaces *xmlns); /** @@ -1826,7 +1826,7 @@ class LIBTSB_EXTERN TSBBase * * @return true if the subclass read from the stream, false otherwise. */ - virtual bool readOtherXML ( XMLInputStream& stream); + virtual bool readOtherXML (XMLInputStream& stream); /** @@ -1896,8 +1896,8 @@ class LIBTSB_EXTERN TSBBase * XMLAttributes set into their specific fields. Be sure to call your * parents implementation of this method as well. */ - virtual void readAttributes (const XMLAttributes& attributes, - const ExpectedAttributes& expectedAttributes); + virtual void readAttributes (const XMLAttributes& attributes, + const ExpectedAttributes& expectedAttributes); /** @@ -1914,7 +1914,7 @@ class LIBTSB_EXTERN TSBBase * Be sure to implement wirteXMLNS() function to write xmlns attributes. * */ - virtual void writeAttributes ( XMLOutputStream& stream) const; + virtual void writeAttributes (XMLOutputStream& stream) const; /** @@ -1923,7 +1923,7 @@ class LIBTSB_EXTERN TSBBase * (if any) to the XMLOutputStream. * */ - virtual void writeXMLNS ( XMLOutputStream& stream) const; + virtual void writeXMLNS (XMLOutputStream& stream) const; /** @@ -1937,7 +1937,7 @@ class LIBTSB_EXTERN TSBBase * Checks that the given default namespace in the given element is valid. * If the given default namespace is not valid, an error is logged. */ - void checkDefaultNamespace(const XMLNamespaces* xmlns, + void checkDefaultNamespace(const XMLNamespaces* xmlns, const std::string& elementName, const std::string& prefix = ""); /** @@ -1952,13 +1952,13 @@ class LIBTSB_EXTERN TSBBase * If the xhtml does not conform to the specification of valid xhtml within * an tsb document, an error is logged. */ - void checkXHTML(const XMLNode *); + void checkXHTML(const XMLNode *); /** * Checks that the math ml ns has been declared */ - const std::string checkMathMLNamespace(const XMLToken elem); + const std::string checkMathMLNamespace(const XMLToken elem); /** * Sets the XML namespace to which this element belongs to. @@ -2012,8 +2012,8 @@ class LIBTSB_EXTERN TSBBase std::string mMetaId; std::string mId; - XMLNode* mNotes; - XMLNode* mTestAnnotation; + XMLNode* mNotes; + XMLNode* mTestAnnotation; TSBDocument* mTSB; TSBNamespaces* mTSBNamespaces; void* mUserData; @@ -2054,7 +2054,7 @@ class LIBTSB_EXTERN TSBBase * Stores the location (line and column) and any XML namespaces (for * roundtripping) declared on this TSB (XML) element. */ - void setTSBBaseFields (const XMLToken& element); + void setTSBBaseFields (const XMLToken& element); /** @@ -2062,7 +2062,7 @@ class LIBTSB_EXTERN TSBBase * * @return true if read an element from the stream */ - bool readTestAnnotation ( XMLInputStream& stream); + bool readTestAnnotation (XMLInputStream& stream); /** @@ -2070,7 +2070,7 @@ class LIBTSB_EXTERN TSBBase * * @return true if read a element from the stream */ - bool readNotes ( XMLInputStream& stream); + bool readNotes (XMLInputStream& stream); /** @endcond */ @@ -2136,12 +2136,6 @@ TSBBase_getParentTSBObject (TSBBase_t *sb); * Returns the ancestor TSBBase_t structure of the given TSBBase_t * structure that corresponds to the given type. * - * This function allows any structure to determine its exact - * location/function within a model. For example a - * StoichiometryMath_t structure has ancestors of type SpeciesReference_t, - * TSBListOf_t(Products/Reactants), Reaction_t, TSBListOfReactions_t and Model_t; - * any of which can be accessed via this function. - * * @param sb the TSBBase_t structure * @param type the typecode (int) of the structure to be returned * diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/TSBError.h b/deviser/pytest_files/test_other_library/test-code/tsb/TSBError.h index ab9e2427e..cad7fe167 100644 --- a/deviser/pytest_files/test_other_library/test-code/tsb/TSBError.h +++ b/deviser/pytest_files/test_other_library/test-code/tsb/TSBError.h @@ -57,39 +57,26 @@ typedef enum , TSBNotUTF8 = 10001 /*!< File does not use UTF-8 encoding. */ , TSBUnrecognizedElement = 10002 /*!< Encountered unrecognized element. */ , TSBNotSchemaConformant = 10003 /*!< Document does not conform to the TSB XML schema. */ -, TSBInvalidMathElement = 10201 -, TSBMissingTestAnnotationNamespace = 10401 /*!< Missing declaration of the XML namespace for the annotation. */ -, TSBDuplicateTestAnnotationNamespaces = 10402 /*!< Multiple annotations using the same XML namespace. */ -, TSBNamespaceInTestAnnotation = 10403 /*!< The TSB XML namespace cannot be used in an TestAnnotation object. */ -, TSBMultipleTestAnnotations = 10404 /*!< Only one TestAnnotation object is permitted under a given TSB object. */ -, TSBTestAnnotationNotElement = 10405 -, TSBNotesNotInXHTMLNamespace = 10801 /*!< Notes must be placed in the XHTML XML namespace. */ -, TSBNotesContainsXMLDecl = 10802 /*!< XML declarations are not permitted in Notes objects. */ -, TSBNotesContainsDOCTYPE = 10803 /*!< XML DOCTYPE elements are not permitted in Notes objects. */ -, TSBInvalidNotesContent = 10804 /*!< Invalid notes content found. */ -, TSBOnlyOneNotesElementAllowed = 10805 /*!< Only one Notes subobject is permitted on a given TSB object. */ -, TsbNSUndeclared = 10101 -, TsbElementNotInNs = 10102 -, TsbDuplicateComponentId = 10301 -, TsbIdSyntaxRule = 10302 -, TSBInvalidMetaidSyntax = 10303 -, InvalidNamespaceOnTSB = 20101 -, AllowedAttributes = 20102 -, TSBEmptyListElement = 20103 -, TsbDocumentAllowedCoreAttributes = 20201 -, TsbDocumentAllowedCoreElements = 20202 -, TsbDocumentAllowedAttributes = 20203 -, TsbDocumentAllowedElements = 20204 -, TsbDocumentLevelMustBeNonNegativeInteger = 20205 -, TsbDocumentVersionMustBeNonNegativeInteger = 20206 -, TsbDocumentLOCommentsAllowedCoreElements = 20207 -, TsbDocumentLOCommentsAllowedCoreAttributes = 20208 -, TsbCommentAllowedCoreAttributes = 20301 -, TsbCommentAllowedCoreElements = 20302 -, TsbCommentAllowedAttributes = 20303 -, TsbCommentContributorMustBeString = 20304 -, TsbCommentNumberMustBeDouble = 20305 -, TsbCommentPointMustBeString = 20306 +, TSBNSUndeclared = 10101 +, TSBElementNotInNs = 10102 +, TSBInvalidMetaidSyntax = 10201 +, TSBNoAnnotationNS = 10301 +, TSBRepeatAnnotationNS = 10302 +, TSBOnlyOneAnnotation = 10303 +, NotesInXHTML = 10401 +, XMLDeclNotes = 10402 +, DOCTYPEInNotes = 10403 +, TSBOnlyOneNotes = 10404 +, TSBTSBDocumentAllowedAttributes = 20101 +, TSBTSBDocumentAllowedElements = 20102 +, TSBTSBDocumentLevelMustBeNonNegativeInteger = 20103 +, TSBTSBDocumentVersionMustBeNonNegativeInteger = 20104 +, TSBTSBDocumentLOCommentAllowedCoreElements = 20201 +, TSBTSBDocumentLOCommentsAllowedCoreAttributes = 20202 +, TSBCommentAllowedAttributes = 20301 +, TSBCommentContributorMustBeString = 20302 +, TSBCommentNumberMustBeDouble = 20303 +, TSBCommentPointMustBeString = 20304 , TSBUnknownCoreAttribute = 99994 /*!< Encountered an unknown attribute in the TSB Core namespace. */ , TSBCodesUpperBound = 99999 /*!< Upper boundary of libTSB-specific diagnostic codes. */ } TSBErrorCode_t; diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/TSBErrorTable.h b/deviser/pytest_files/test_other_library/test-code/tsb/TSBErrorTable.h index aae6825a2..5516de975 100644 --- a/deviser/pytest_files/test_other_library/test-code/tsb/TSBErrorTable.h +++ b/deviser/pytest_files/test_other_library/test-code/tsb/TSBErrorTable.h @@ -115,380 +115,236 @@ static const tsbErrorTableEntry tsbErrorTable[] = } }, - //10201 - { - TSBInvalidMathElement, - "Invalid MathML", - LIBTSB_CAT_MATHML_CONSISTENCY, - LIBTSB_SEV_ERROR, - "All MathML content in TSB must appear within a element, and the " - " element must be either explicitly or implicitly in the XML " - "namespace \"http://www.w3.org/1998/Math/MathML\".", - {"" - } - }, - - //10401 - { - TSBMissingTestAnnotationNamespace, - "Missing declaration of the XML namespace for the annotation", - LIBTSB_CAT_TSB, - LIBTSB_SEV_ERROR, - "Every top-level element within an annotation element must " - "have a namespace declared.", - {"" - } - }, - - //10402 - { - TSBDuplicateTestAnnotationNamespaces, - "Multiple annotations using the same XML namespace", - LIBTSB_CAT_TSB, - LIBTSB_SEV_ERROR, - "There cannot be more than one top-level element using a " - "given namespace inside a given annotation element. ", - {"" - } - }, - - //10403 - { - TSBNamespaceInTestAnnotation, - "The TSB XML namespace cannot be used in an TestAnnotation object", - LIBTSB_CAT_TSB, - LIBTSB_SEV_ERROR, - "Top-level elements within an annotation element cannot use any TSB " - "namespace, whether explicitly or implicitly (by failing " - "to declare any namespace).", - {"" - } - }, - - //10404 - { - TSBMultipleTestAnnotations, - "Only one TestAnnotation object is permitted under a given TSB object", - LIBTSB_CAT_TSB, - LIBTSB_SEV_ERROR, - "A given TSB object may contain at most one element.", - {"" - } - }, - - //10801 - { - TSBNotesNotInXHTMLNamespace, - "Notes must be placed in the XHTML XML namespace", - LIBTSB_CAT_TSB, - LIBTSB_SEV_ERROR, - "The contents of the element must be explicitly placed in the " - "XHTML XML namespace.", - {"" - } - }, - - //10802 - { - TSBNotesContainsXMLDecl, - "XML declarations are not permitted in Notes objects", - LIBTSB_CAT_TSB, - LIBTSB_SEV_ERROR, - "The contents of the element must not contain an XML declaration " - "(i.e., a string of the form \"\" " - "or similar).", - {"" - } - }, - - //10803 - { - TSBNotesContainsDOCTYPE, - "XML DOCTYPE elements are not permitted in Notes objects", - LIBTSB_CAT_TSB, - LIBTSB_SEV_ERROR, - "The contents of the element must not contain an XML DOCTYPE " - "declaration (i.e., a string beginning with the characters \" element. ", - {"" - } - }, - - //10805 - { - TSBOnlyOneNotesElementAllowed, - "Only one Notes subobject is permitted on a given TSB object", - LIBTSB_CAT_TSB, - LIBTSB_SEV_ERROR, - "A given TSB object may contain at most one element. ", - {"" - } - }, - /* -------------------------------------------------------------------------- * Boundary marker. TSB specific errors. * ----------------------------------------------------------------------- */ // 10101 - { TsbNSUndeclared, - "The Tsb namespace is not correctly declared.", + { TSBNSUndeclared, + "The TSB namespace is not correctly declared.", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "To conform to the Package specification for SBML Level 0 Version 1, an " - "SBML document must declare " - "'http://www.sbml.org/sbml/level0/version1/tsb/version0' as the " - "XMLNamespace to use for elements of this package.", - { "L3V1 Tsb V1 Section 3.1" + "To conform to the tsb specification for TSB Level 1 Version 1, an TSB " + "document must declare 'http://testsbxml.org/l1v1' as the XMLNamespace to " + "use for elements of this package.", + { "TSB L1V1 Section " } }, // 10102 - { TsbElementNotInNs, - "Element not in Tsb namespace", + { TSBElementNotInNs, + "Element not in TSB namespace", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "Wherever they appear in an SBML document, elements and attributes from the " - "Package must use the " - "'http://www.sbml.org/sbml/level0/version1/tsb/version0' namespace, " - "declaring so either explicitly or implicitly.", - { "L3V1 Tsb V1 Section 3.1" + "Wherever they appear in a TSB document, elements and attributes from the " + "tsb must use the 'http://testsbxml.org/l1v1' namespace, declaring so " + "either explicitly or implicitly.", + { "TSB L1V1 Section " } }, - // 10301 - { TsbDuplicateComponentId, - "Duplicate 'id' attribute value", + // 10201 + { TSBInvalidMetaidSyntax, + "Invalid SId syntax", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "(Extends validation rule #10301 in the SBML Level 3 Core specification. TO " - "DO list scope of ids)", - { "L3V1 Tsb V1 Section" + "The value of a 'tsb:metaid' must conform to the syntax of the XML Type " + "ID", + { "TSB L1V1 Section " } }, - // 10302 - { TsbIdSyntaxRule, - "Invalid SId syntax", + // 10301 + { TSBNoAnnotationNS, + "No ns for TestAnnotation", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "The value of a 'tsb:id' must conform to the syntax of the data type " - "'SId'", - { "L3V1 Tsb V1 Section" + "Every top-level XML element within an object must have an " + "XML namespace declared.", + { "TSB L1V1 Section " } }, - // 10303 - { TSBInvalidMetaidSyntax, - "Invalid SId syntax", + // 10302 + { TSBRepeatAnnotationNS, + "Repeat ns for TestAnnotation", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "The value of a 'tsb:metaid' must conform to the syntax of the XML Type " - "ID", - { "L3V1 Tsb V1 Section" + "A given XML namespace cannot be the namespace of more than one " + "top-levelelement within a given object.", + { "TSB L1V1 Section " } }, - // 20101 - { InvalidNamespaceOnTSB, - "Invalid namespace", + // 10303 + { TSBOnlyOneAnnotation, + "Only one TestAnnotation", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "Invalid namespace declared.", - { "L3V1 Tsb V1 Section" + "A given TSB element may contain at most one subobject.", + { "TSB L1V1 Section " } }, - // 20102 - { AllowedAttributes, - "Allowed attributes", + // 10401 + { NotesInXHTML, + "Notes not in XHTML", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "Allowed attributes", - { "L3V1 Tsb V1 Section" + "The contents of a object must be explicitly placed in the XHTML " + "XML namespace. ", + { "TSB L1V1 Section " } }, - // 20103 - { TSBEmptyListElement, - "No empty listOf", + // 10402 + { XMLDeclNotes, + "No XML decl in Notes", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "No empty lists", - { "L3V1 Tsb V1 Section" + "The contents of a object must not contain an XML declaration, " + "a string of the form '' or + similar.", + { "TSB L1V1 Section " } }, - // 20201 - { TsbDocumentAllowedCoreAttributes, - "Core attributes allowed on .", + // 10403 + { DOCTYPEInNotes, + "No DOCTYPE in Notes", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "A object may have the optional SBML Level 3 Core attributes " - "'metaid' and 'sboTerm'. No other attributes from the SBML Level 3 Core " - "namespaces are permitted on a .", - { "L3V1 Tsb V1 Section" + "The content of a object must not contain an XML DOCTYPE " + "declaration, a string beginning with the characters '.", + // 10404 + { TSBOnlyOneNotes, + "Only one Notes", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "A object may have the optional SBML Level 3 Core subobjects for " - "notes and annotations. No other elements from the SBML Level 3 Core " - "namespaces are permitted on a .", - { "L3V1 Tsb V1 Section" + "A given TSB element may contain at most one subobject.", + { "TSB L1V1 Section " } }, - // 20203 - { TsbDocumentAllowedAttributes, - "Attributes allowed on .", + // 20101 + { TSBTSBDocumentAllowedAttributes, + "Attributes allowed on .", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "A object must have the required attributes 'tsb:level' and " - "'tsb:version'. No other attributes from the SBML Level 3 Test SB XML " - "Library namespaces are permitted on a object. ", - { "L3V1 Tsb V1 Section" + "A object must have the required attributes 'tsb:level' and " + "'tsb:version', and may have the optional attribute 'tsb:metaid'. No other " + "attributes from the TSB Level 1 Version 1 namespaces are permitted on a " + " object. ", + { "TSB L1V1 Section " } }, - // 20204 - { TsbDocumentAllowedElements, - "Elements allowed on .", + // 20102 + { TSBTSBDocumentAllowedElements, + "Elements allowed on .", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "A object may contain one and only one instance of the " - " element. No other elements from the SBML Level 3 Test SB " - "XML Library namespaces are permitted on a object. ", - { "L3V1 Tsb V1 Section" + "Apart from the general and subobjects permitted " + "on all TSB components, A object may contain one and only one " + "instance of the element. No other objects from the TSB " + "Level 1 Version 1 namespaces are permitted on a object. ", + { "TSB L1V1 Section " } }, - // 20205 - { TsbDocumentLevelMustBeNonNegativeInteger, + // 20103 + { TSBTSBDocumentLevelMustBeNonNegativeInteger, "The 'level' attribute must be NonNegativeInteger.", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "The attribute 'tsb:level' on a must have a value of data type " - "'integer', and must be non negative.", - { "L3V1 Tsb V1 Section" + "The attribute 'tsb:level' on a must have a value of data " + "type 'integer', and must be non negative.", + { "TSB L1V1 Section " } }, - // 20206 - { TsbDocumentVersionMustBeNonNegativeInteger, + // 20104 + { TSBTSBDocumentVersionMustBeNonNegativeInteger, "The 'version' attribute must be NonNegativeInteger.", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "The attribute 'tsb:version' on a must have a value of data type " - "'integer', and must be non negative.", - { "L3V1 Tsb V1 Section" + "The attribute 'tsb:version' on a must have a value of data " + "type 'integer', and must be non negative.", + { "TSB L1V1 Section " } }, - // 20207 - { TsbDocumentLOCommentsAllowedCoreElements, - "Core elements allowed on .", + // 20201 + { TSBTSBDocumentLOCommentAllowedCoreElements, + "Core elements allowed on .", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "Apart from the general notes and annotations subobjects permitted on all " - "SBML objects, a container object may only contain " + "Apart from the general and subobjects permitted " + "on all TSB objects, a container object may only contain " " objects.", - { "L3V1 Tsb V1 Section" + { "TSB L1V1 Section " } }, - // 20208 - { TsbDocumentLOCommentsAllowedCoreAttributes, + // 20202 + { TSBTSBDocumentLOCommentsAllowedCoreAttributes, "Core attributes allowed on .", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, - "A object may have the optional SBML Level 3 Core " - "attributes 'metaid' and 'sboTerm'. No other attributes from the SBML Level " - "3 Core namespaces are permitted on a object.", - { "L3V1 Tsb V1 Section" + "A object may have the optional attribute 'metaid'. No " + "other attributes from the TSB Level 1 Version 1 namespaces are permitted " + "on a object.", + { "TSB L1V1 Section " } }, // 20301 - { TsbCommentAllowedCoreAttributes, - "Core attributes allowed on .", - LIBTSB_CAT_GENERAL_CONSISTENCY, - LIBTSB_SEV_ERROR, - "A object may have the optional SBML Level 3 Core attributes " - "'metaid' and 'sboTerm'. No other attributes from the SBML Level 3 Core " - "namespaces are permitted on a .", - { "L3V1 Tsb V1 Section" - } - }, - - // 20302 - { TsbCommentAllowedCoreElements, - "Core elements allowed on .", - LIBTSB_CAT_GENERAL_CONSISTENCY, - LIBTSB_SEV_ERROR, - "A object may have the optional SBML Level 3 Core subobjects for " - "notes and annotations. No other elements from the SBML Level 3 Core " - "namespaces are permitted on a .", - { "L3V1 Tsb V1 Section" - } - }, - - // 20303 - { TsbCommentAllowedAttributes, + { TSBCommentAllowedAttributes, "Attributes allowed on .", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, "A object must have the required attributes 'tsb:contributor' and " - "'tsb:number', and may have the optional attribute 'tsb:point'. No other " - "attributes from the SBML Level 3 Test SB XML Library namespaces are " - "permitted on a object. ", - { "L3V1 Tsb V1 Section" + "'tsb:number', and may have the optional attributes 'tsb:point' and " + "'tsb:metaid'. No other attributes from the TSB Level 1 Version 1 " + "namespaces are permitted on a object. ", + { "TSB L1V1 Section " } }, - // 20304 - { TsbCommentContributorMustBeString, + // 20302 + { TSBCommentContributorMustBeString, "The 'contributor' attribute must be String.", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, "The attribute 'tsb:contributor' on a must have a value of data " "type 'string'.", - { "L3V1 Tsb V1 Section" + { "TSB L1V1 Section " } }, - // 20305 - { TsbCommentNumberMustBeDouble, + // 20303 + { TSBCommentNumberMustBeDouble, "The 'number' attribute must be Double.", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, "The attribute 'tsb:number' on a must have a value of data type " "'double'.", - { "L3V1 Tsb V1 Section" + { "TSB L1V1 Section " } }, - // 20306 - { TsbCommentPointMustBeString, + // 20304 + { TSBCommentPointMustBeString, "The 'point' attribute must be String.", LIBTSB_CAT_GENERAL_CONSISTENCY, LIBTSB_SEV_ERROR, "The attribute 'tsb:point' on a must have a value of data type " "'string'.", - { "L3V1 Tsb V1 Section" + { "TSB L1V1 Section " } }, diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/TSBNamespaces.h b/deviser/pytest_files/test_other_library/test-code/tsb/TSBNamespaces.h index 76e0520e6..e4b5c6cd3 100644 --- a/deviser/pytest_files/test_other_library/test-code/tsb/TSBNamespaces.h +++ b/deviser/pytest_files/test_other_library/test-code/tsb/TSBNamespaces.h @@ -45,6 +45,7 @@ #include #include + #include #include diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/TSBOperationReturnValues.cpp b/deviser/pytest_files/test_other_library/test-code/tsb/TSBOperationReturnValues.cpp new file mode 100644 index 000000000..1dba608b5 --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/TSBOperationReturnValues.cpp @@ -0,0 +1,197 @@ +/** + * @file TSBOperationReturnValues.cpp + * @brief Implementation of the TSBOperationReturnValues class. + * @author DEVISER + * + * + */ + + + +#include +#include + +LIBTSB_CPP_NAMESPACE_BEGIN + +static TSBOperationReturnValues_t TSB_OPERATION_RETURN_VALUES_INDICES[] = +{ + LIBTSB_OPERATION_SUCCESS + , LIBTSB_INDEX_EXCEEDS_SIZE + , LIBTSB_UNEXPECTED_ATTRIBUTE + , LIBTSB_OPERATION_FAILED + , LIBTSB_INVALID_ATTRIBUTE_VALUE + , LIBTSB_INVALID_OBJECT + , LIBTSB_DUPLICATE_OBJECT_ID + , LIBTSB_LEVEL_MISMATCH + , LIBTSB_VERSION_MISMATCH + , LIBTSB_INVALID_XML_OPERATION + , LIBTSB_NAMESPACES_MISMATCH + , LIBTSB_DUPLICATE_ANNOTATION_NS + , LIBTSB_ANNOTATION_NAME_NOT_FOUND + , LIBTSB_ANNOTATION_NS_NOT_FOUND + , LIBTSB_MISSING_METAID + , LIBTSB_DEPRECATED_ATTRIBUTE +}; + +static const char* TSB_OPERATION_RETURN_VALUES_STRINGS[] = +{ + /* LIBTSB_OPERATION_SUCCESS = 0 */ + "The operation was successful. " + , /*LIBTSB_INDEX_EXCEEDS_SIZE = -1 */ + "An index parameter exceeded the bounds of a data array or other " + "collection used in the operation. This return value is typically " + "returned by methods that take index numbers to refer to lists " + "of objects, when the caller has provided an index that exceeds " + "the bounds of the list. LibTSB provides methods for checking the " + "size of list/sequence/collection structures, and callers should " + "verify the sizes before calling methods that take index numbers. " + + , /*LIBTSB_UNEXPECTED_ATTRIBUTE = -2*/ + "The attribute that is the subject of this operation is not valid " + "for the combination of TSB Level and Version for the underlying " + "object. This can happen because libTSB strives to offer a uniform " + "API for all TSB Levels and Versions, but some object attributes and " + "elements are not defined for all TSB Levels and Versions. Calling " + "programs are expected to be aware of which object structures they " + "are working with, but when errors of this kind occur, they are " + "reported using this return value. " + + , /*LIBTSB_OPERATION_FAILED = -3*/ + "The requested action could not be performed. This can occur in " + "a variety of contexts, such as passing a null object as a parameter " + "in a situation where it does not make sense to permit a null object. " + " " + + , /*LIBTSB_INVALID_ATTRIBUTE_VALUE = -4*/ + "A value passed as an argument to the method is not of a type that " + "is valid for the operation or kind of object involved. For example, " + "this return code is used when a calling program attempts to set an " + "TSB object identifier to a string whose syntax does not conform to " + "the TSB identifier syntax. " + + , /*LIBTSB_INVALID_OBJECT = -5*/ + "The object passed as an argument to the method is not of a type " + "that is valid for the operation or kind of object involved. For " + "example, handing an invalidly-constructed ASTNode to a method " + "expecting an ASTNode will result in this error. " + + , /*LIBTSB_DUPLICATE_OBJECT_ID = -6*/ + "There already exists an object with this identifier in the " + "context where this operation is being attempted. This error is " + "typically returned in situations where TSB object identifiers must be " + "unique, such as attempting to add two species with the same identifier " + "to a model. " + + , /*LIBTSB_LEVEL_MISMATCH = -7*/ + "The TSB Level associated with the object does not match the Level " + "of the parent object. This error can happen when an TSB component " + "such as a species or compartment object is created outside of a model " + "and a calling program then attempts to add the object to a model that " + "has a different TSB Level defined. " + + , /*LIBTSB_VERSION_MISMATCH = -8*/ + "The TSB Version within the TSB Level associated with the object " + "does not match the Version of the parent object. This error can " + "happen when an TSB component such as a species or compartment object " + "is created outside of a model and a calling program then attempts to " + "add the object to a model that has a different TSB Level+Version " + "combination. " + + , /*LIBTSB_INVALID_XML_OPERATION = -9*/ + "The XML operation attempted is not valid for the object or context " + "involved. This error is typically returned by the XML interface layer " + "of libTSB, when a calling program attempts to construct or manipulate " + "XML in an invalid way. " + + , /*LIBTSB_NAMESPACES_MISMATCH = -10*/ + "The TSB Namespaces associated with the object " + "do not match the TSB Namespaces of the parent object. This error can " + "happen when an TSB component such as a species or compartment object " + "is created outside of a model and a calling program then attempts to " + "add the object to a model that has a different TSB Namespaces " + "combination. " + + , /*LIBTSB_DUPLICATE_ANNOTATION_NS = -11*/ + "There already exists a top level annotation with the same namespace as " + "annotation being appended. This error is " + "typically returned in situations where the appendTestAnnotation function " + "is being used to add an annotation that has a namespace that is already " + "present in the existing annotation. " + + , /*LIBTSB_ANNOTATION_NAME_NOT_FOUND = -12*/ + "The existing annotation does not have a top-level element with " + "the given name. This error is " + "typically returned in situations where the " + "replaceTopLevelTestAnnotationElement function or " + "the removeTopLevelTestAnnotationElement function " + "is being used to replace or remove an annotation with a name that does " + "not match the name of any top-level element that is already " + "present in the existing annotation. " + + , /*LIBTSB_ANNOTATION_NS_NOT_FOUND = -13*/ + "The existing annotation does not have a top-level element with " + "the given namespace. This error is " + "typically returned in situations where the " + "replaceTopLevelTestAnnotationElement function or " + "the removeTopLevelTestAnnotationElement function " + "is being used to replace or remove an annotation with a namespace that does " + "not match the namespace of any top-level element that is already " + "present in the existing annotation. " + + , /* LIBTSB_MISSING_METAID = -14*/ + "The requested action cannot be performed as the target object does not have " + "the metaid attribute set. " + + , /* LIBTSB_DEPRECATED_ATTRIBUTE = -15*/ + "The attribute that is the subject of this operation has been deprecated " + "for the combination of TSB Level and Version for the underlying " + "object. " + +}; + +LIBTSB_EXTERN +const char * +TSBOperationReturnValue_toString (int returnValue) +{ + int length = sizeof(TSB_OPERATION_RETURN_VALUES_INDICES)/sizeof(TSBOperationReturnValues_t); + for (int i = 0; i < length; ++i) + { + if (TSB_OPERATION_RETURN_VALUES_INDICES[i] == returnValue) + return TSB_OPERATION_RETURN_VALUES_STRINGS[i]; + } + + return NULL; +} + + +LIBTSB_CPP_NAMESPACE_END + diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/TSBOperationReturnValues.h b/deviser/pytest_files/test_other_library/test-code/tsb/TSBOperationReturnValues.h new file mode 100644 index 000000000..4a1d748cc --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/TSBOperationReturnValues.h @@ -0,0 +1,201 @@ +/** + * @file TSBOperationReturnValues.h + * @brief Definition of the TSBOperationReturnValues class. + * @author DEVISER + * + * + * + * @class TSBOperationReturnValues + * @sbmlbrief{} TODO:Definition of the TSBOperationReturnValues class. + */ + + + +#ifndef LIBTSB_OPERATION_RETURN_VALUES_H +#define LIBTSB_OPERATION_RETURN_VALUES_H + +#include +#include + + +LIBTSB_CPP_NAMESPACE_BEGIN + +BEGIN_C_DECLS + +/** + * @enum OperationReturnValues_t + * LibTSB diagnostic return codes. + * + * Many methods in libTSB return a status code to indicate whether the + * operation requested by the caller succeeded or failed. This enumeration + * lists all the possible return codes from any libTSB methods. + */ +typedef enum +{ + LIBTSB_OPERATION_SUCCESS = 0 + /*!< The operation was successful. */ + + , LIBTSB_INDEX_EXCEEDS_SIZE = -1 + /*!< An index parameter exceeded the bounds of a data array or other + * collection used in the operation. This return value is typically + * returned by methods that take index numbers to refer to lists + * of objects, when the caller has provided an index that exceeds + * the bounds of the list. LibTSB provides methods for checking the + * size of list/sequence/collection structures, and callers should + * verify the sizes before calling methods that take index numbers. */ + + , LIBTSB_UNEXPECTED_ATTRIBUTE = -2 + /*!< The attribute that is the subject of this operation is not valid + * for the combination of TSB Level and Version for the underlying + * object. This can happen because libTSB strives to offer a uniform + * API for all TSB Levels and Versions, but some object attributes and + * elements are not defined for all TSB Levels and Versions. Calling + * programs are expected to be aware of which object structures they + * are working with, but when errors of this kind occur, they are + * reported using this return value. */ + + , LIBTSB_OPERATION_FAILED = -3 + /*!< The requested action could not be performed. This can occur in + * a variety of contexts, such as passing a null object as a parameter + * in a situation where it does not make sense to permit a null object. + */ + + , LIBTSB_INVALID_ATTRIBUTE_VALUE = -4 + /*!< A value passed as an argument to the method is not of a type that + * is valid for the operation or kind of object involved. For example, + * this return code is used when a calling program attempts to set an + * TSB object identifier to a string whose syntax does not conform to + * the TSB identifier syntax. */ + + , LIBTSB_INVALID_OBJECT = -5 + /*!< The object passed as an argument to the method is not of a type + * that is valid for the operation or kind of object involved. For + * example, handing an invalidly-constructed ASTNode to a method + * expecting an ASTNode will result in this error. */ + + , LIBTSB_DUPLICATE_OBJECT_ID = -6 + /*!< There already exists an object with this identifier in the + * context where this operation is being attempted. This error is + * typically returned in situations where TSB object identifiers must be + * unique, such as attempting to add two species with the same identifier + * to a model. */ + + , LIBTSB_LEVEL_MISMATCH = -7 + /*!< The TSB Level associated with the object does not match the Level + * of the parent object. This error can happen when an TSB component + * such as a species or compartment object is created outside of a model + * and a calling program then attempts to add the object to a model that + * has a different TSB Level defined. */ + + , LIBTSB_VERSION_MISMATCH = -8 + /*!< The TSB Version within the TSB Level associated with the object + * does not match the Version of the parent object. This error can + * happen when an TSB component such as a species or compartment object + * is created outside of a model and a calling program then attempts to + * add the object to a model that has a different TSB Level+Version + * combination. */ + + , LIBTSB_INVALID_XML_OPERATION = -9 + /*!< The XML operation attempted is not valid for the object or context + * involved. This error is typically returned by the XML interface layer + * of libTSB, when a calling program attempts to construct or manipulate + * XML in an invalid way. */ + + , LIBTSB_NAMESPACES_MISMATCH = -10 + /*!< The TSB Namespaces associated with the object + * do not match the TSB Namespaces of the parent object. This error can + * happen when an TSB component such as a species or compartment object + * is created outside of a model and a calling program then attempts to + * add the object to a model that has a different TSB Namespaces + * combination. */ + + , LIBTSB_DUPLICATE_ANNOTATION_NS = -11 + /*!< There already exists a top level annotation with the same namespace as + * annotation being appended. This error is + * typically returned in situations where the appendAnnotation function + * is being used to add an annotation that has a namespace that is already + * present in the existing annotation. */ + + , LIBTSB_ANNOTATION_NAME_NOT_FOUND = -12 + /*!< The existing annotation does not have a top-level element with + * the given name. This error is + * typically returned in situations where the + * replaceTopLevelAnnotationElement function or + * the removeTopLevelAnnotationElement function + * is being used to replace or remove an annotation with a name that does + * not match the name of any top-level element that is already + * present in the existing annotation. */ + + , LIBTSB_ANNOTATION_NS_NOT_FOUND = -13 + /*!< The existing annotation does not have a top-level element with + * the given namespace. This error is + * typically returned in situations where the + * replaceTopLevelAnnotationElement function or + * the removeTopLevelAnnotationElement function + * is being used to replace or remove an annotation with a namespace that does + * not match the namespace of any top-level element that is already + * present in the existing annotation. */ + + , LIBTSB_MISSING_METAID = -14 + /*!< The requested action cannot be performed as the target object does not have + * the metaid attribute set. */ + + , LIBTSB_DEPRECATED_ATTRIBUTE = -15 + /*!< The attribute that is the subject of this operation has been deprecated + * for the combination of TSB Level and Version for the underlying + * object. */ + +} TSBOperationReturnValues_t; + +/** + * This method takes an TSB operation return value and returns a string representing + * the code. + * + * @param returnValue the operation return value to convert to a string + * + * @return a human readable name for the given + * @if clike #OperationReturnValues_t value@else operation return value @endif. + * + * @note The caller does not own the returned string and is therefore not + * allowed to modify it. + */ +LIBTSB_EXTERN +const char * +TSBOperationReturnValue_toString (int returnValue); + +END_C_DECLS + +LIBTSB_CPP_NAMESPACE_END + + +#endif /* LIBTSB_OPERATION_RETURN_VALUES_H */ + diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/VERSION.txt b/deviser/pytest_files/test_other_library/test-code/tsb/VERSION.txt new file mode 100644 index 000000000..332145cb1 --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/VERSION.txt @@ -0,0 +1,2 @@ +1.0.0 + diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/common.h b/deviser/pytest_files/test_other_library/test-code/tsb/common.h new file mode 100644 index 000000000..e1c051522 --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/common.h @@ -0,0 +1,122 @@ +/** + * @file common.h + * @brief Definition of the common class. + * @author DEVISER + * + * + * + * @class common + * @sbmlbrief{} TODO:Definition of the common class. + */ + + +#ifndef LIBTSB_COMMON_H +#define LIBTSB_COMMON_H 1 + + +#include + + +#include + + +#if STDC_HEADERS +# include +# include +# include +# include +# include +#endif + +#if HAVE_MATH_H +# include +#endif + +#if HAVE_IEEFP_H +# include +#endif + +#ifndef errno + extern int errno; +#endif + + +/** + * Default format used by libTSB when writing out floating-point numbers + * into the XML produced by libTSB. This is used by + * StringBuffer_appendReal. + */ +#define LIBTSB_FLOAT_FORMAT "%.15g" + +#define LIBTSB_DOUBLE_PRECISION 15 + +static const int TSB_INT_MAX = 2147483647; +static const int TSB_INT_MIN = -2147483647 - 1; + +/* + * Sometimes the line/column numbers reported by the underlying parsers are + * simply invalid. This especially occurs in error situations when the + * error is severe. Typically you're not supposed to call the parsers' + * getline()/getcolumn() functions in those situations, but it's hard to + * avoid because of the flow of control in our code. The problem is, in + * some cases, calling the parser's getline()/getcolumn() functions results + * in a segmentation fault. (Case in point: this was happening using + * Xerces 2.8 on 32-bit systems.) We need to communicate that a + * line/column number value is actually invalid or meaningless. + * + * Doing that presents a new problem: our line/column number values are + * unsigned integers, which thus only allows 2 states to be + * communicated. (Explanation: you could use 0 to communicate an invalid + * state and let all other values indicate a valid state. If we had signed + * integers, we could communicate 3 state values, using negative, 0, and + * positive values for the different states.) Unfortunately we can't use 0 + * because that value is already being used to communicate a different + * meaning between users of XMLError objects. + * + * The following is a bit of a hack, but not completely unrealistic: we use + * the largest possible value of the data type used to represent + * line/column numbers. The probability that an error in an file will + * involve these specific numbers is vanishingly small. Thus, we can say + * that if user code encounters these values as line/column numbers, they + * should assume they are actually meaningless and no valid line/column + * number could be provided by the parser. + */ + +#define LIBTSB_UNKNOWN_LINE TSB_INT_MAX +#define LIBTSB_UNKNOWN_COLUMN TSB_INT_MAX + + +#include +#include +#include + +#endif /* LIBTSB_COMMON_H */ diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/extern.h b/deviser/pytest_files/test_other_library/test-code/tsb/extern.h new file mode 100644 index 000000000..e6f9f4f24 --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/extern.h @@ -0,0 +1,120 @@ +/** + * @file extern.h + * @brief Definition of the extern class. + * @author DEVISER + * + * + * + * @class extern + * @sbmlbrief{} TODO:Definition of the extern class. + */ + + + +#ifndef LIBTSB_EXTERN_H +#define LIBTSB_EXTERN_H + +#include + +#if ( defined(WIN32) && !defined(CYGWIN) && !defined(__MINGW32__)) + +#if ( ! defined LIBTSB_STATIC ) +/** + * The following ifdef block is the standard way of creating macros which + * make exporting from a DLL simpler. All files within this DLL are + * compiled with the LIBTSB_EXPORTS symbol defined on the command line. + * This symbol should not be defined on any project that uses this + * DLL. This way any other project whose source files include this file see + * LIBTSB_EXTERN functions as being imported from a DLL, wheras this DLL + * sees symbols defined with this macro as being exported. + * + * (From Andrew Finney's sbwdefs.h, with "SBW" replaced by "LIBTSB" :) + */ +#if defined(LIBTSB_EXPORTS) +# define LIBTSB_EXTERN __declspec(dllexport) +#else +# define LIBTSB_EXTERN __declspec(dllimport) +#endif + +#else +# define LIBTSB_EXTERN +#endif /* LIBTSB_STATIC */ + +/** + * Disable MSVC++ warning C4800: 'const int' : forcing value to bool 'true' + * or 'false' (performance warning). + */ +#pragma warning(disable: 4800) + +/** + * Disable MSVC++ warning C4291: no matching operator delete found. + */ +#pragma warning(disable: 4291) + +/** + * Disable MSVC++ warning C4251: class 'type' needs to have dll-interface + * to be used by clients of class 'type2'. + * + * For an explanation of why this is safe, see: + * - http://www.unknownroad.com/rtfm/VisualStudio/warningC4251.html + */ +#pragma warning(disable: 4251) +#pragma warning(disable: 4275) + +#else + +/** + * LIBTSB_EXTERN is used under Windows to simplify exporting functions + * from a DLL. When compiling under Windows, all files within this DLL are + * compiled with the LIBTSB_EXPORTS symbol defined on the command line. + * This in turn causes extern.h to define a different version of + * LIBTSB_EXTERN that is appropriate for exporting functions to client + * code that uses the DLL. + */ +#define LIBTSB_EXTERN + +#endif /* WIN32 */ + +#undef BEGIN_C_DECLS +#undef END_C_DECLS + +#if defined(__cplusplus) +# define BEGIN_C_DECLS extern "C" { +# define END_C_DECLS } +#else +# define BEGIN_C_DECLS +# define END_C_DECLS +#endif + + +#endif /** LIBTSB_EXTERN_H **/ + diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-config-common.h.cmake b/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-config-common.h.cmake new file mode 100644 index 000000000..65ccbd3b1 --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-config-common.h.cmake @@ -0,0 +1,39 @@ +/** + * @file libtsb-config-common.h.cmake + * @brief Configuration variables + */ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_CHECK_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_EXPAT_H 1 + +/* Define to 1 to use the Expat XML library */ +#cmakedefine USE_EXPAT + + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_IEEEFP_H 1 + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine STDC_HEADERS 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MATH_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the `m' library (-lm). */ +#cmakedefine HAVE_LIBM 1 + +/* Define to 1 to enable primitive memory tracing. */ +#cmakedefine TRACE_MEMORY + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#cmakedefine WORDS_BIGENDIAN 1 diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-config.h b/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-config.h new file mode 100644 index 000000000..ceee9e39f --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-config.h @@ -0,0 +1,54 @@ +/** + * @file libtsb-config.h + * @brief Definition of the libtsb-config class. + * @author DEVISER + * + * + * + * @class libtsb-config + * @sbmlbrief{} TODO:Definition of the libtsb-config class. + */ + + + +#ifndef LIBTSB_CONFIG_H +#define LIBTSB_CONFIG_H 1 + +#include + +#include + +#include + + +#endif /* LIBTSB_CONFIG_H */ + diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-namespace.h.cmake b/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-namespace.h.cmake new file mode 100644 index 000000000..8575bd23b --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-namespace.h.cmake @@ -0,0 +1,40 @@ +/** + * @file libtsb-namespace.h + * @brief Defines C++ namespace of libTSB + */ + + +#ifndef LIBTSB_NAMESPACE_H +#define LIBTSB_NAMESPACE_H 1 + +/* + * + * The idea of the following marcors are borrowed from + * Xerces-C++ XML Parser (http://xerces.apache.org/xerces-c/). + * + */ + +/* Define to enable libTSB C++ namespace */ +#cmakedefine LIBTSB_USE_CPP_NAMESPACE 1 + + +#if defined(__cplusplus) && defined(LIBTSB_USE_CPP_NAMESPACE) && !defined(SWIG) + /* C++ namespace of libTSB */ + #define LIBTSB_CPP_NAMESPACE libtsb + #define LIBTSB_CPP_NAMESPACE_BEGIN namespace LIBTSB_CPP_NAMESPACE { + #define LIBTSB_CPP_NAMESPACE_END } + #define LIBTSB_CPP_NAMESPACE_USE using namespace LIBTSB_CPP_NAMESPACE; + #define LIBTSB_CPP_NAMESPACE_QUALIFIER LIBTSB_CPP_NAMESPACE:: + + namespace LIBTSB_CPP_NAMESPACE {} +#else + #define LIBTSB_CPP_NAMESPACE + #define LIBTSB_CPP_NAMESPACE_BEGIN + #define LIBTSB_CPP_NAMESPACE_END + #define LIBTSB_CPP_NAMESPACE_USE + #define LIBTSB_CPP_NAMESPACE_QUALIFIER +#endif + + +#endif /* LIBTSB_NAMESPACE_H */ + diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-version.cpp b/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-version.cpp new file mode 100644 index 000000000..6f94e5490 --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-version.cpp @@ -0,0 +1,71 @@ +/** + * @file libtsb-version.cpp + * @brief Implementation of the libtsb-version class. + * @author DEVISER + * + * + */ + + + +#include "tsb/common/libtsb-version.h" +#include + + +LIBTSB_CPP_NAMESPACE_BEGIN + +LIBTSB_EXTERN +int +getLibTSBVersion() +{ + return LIBTSB_VERSION; +} + + +LIBTSB_EXTERN +const char* +getLibTSBDottedVersion() +{ + return LIBTSB_DOTTED_VERSION; +} + + +LIBTSB_EXTERN +const char* +getLibTSBVersionString() +{ + return LIBTSB_VERSION_STRING; +} + +LIBTSB_CPP_NAMESPACE_END + + diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-version.h.cmake b/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-version.h.cmake new file mode 100644 index 000000000..89456fc31 --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/libtsb-version.h.cmake @@ -0,0 +1,83 @@ +/** + * @file libtsb-version.h + * @brief Define libTSB version numbers for access from client software. + * + */ + + +#ifndef LIBTSB_VERSION_H +#define LIBTSB_VERSION_H + +#include + + +/** + * LIBTSB_DOTTED_VERSION: + * + * A version string of the form "1.2.3". + */ +#define LIBTSB_DOTTED_VERSION "@PACKAGE_VERSION@" + + +/** + * LIBTSB_VERSION: + * + * The version as an integer: version 1.2.3 becomes 10203. Since the major + * number comes first, the overall number will always increase when a new + * libTSB is released, making it easy to use less-than and greater-than + * comparisons when testing versions numbers. + */ +#define LIBTSB_VERSION @LIBTSB_VERSION_NUMERIC@ + + +/** + * LIBTSB_VERSION_STRING: + * + * The numeric version as a string: version 1.2.3 becomes "10203". + */ +#define LIBTSB_VERSION_STRING "@LIBTSB_VERSION_NUMERIC@" + + +LIBTSB_CPP_NAMESPACE_BEGIN +BEGIN_C_DECLS + +/** + * Returns the version number of this copy of libTSB as an integer. + * + * @return the libTSB version as an integer; version 1.2.3 becomes 10203. + */ +LIBTSB_EXTERN +int +getLibTSBVersion(); + + +/** + * Returns the version number of this copy of libTSB as a string. + * + * @return the libTSB version as a string; version 1.2.3 becomes + * "1.2.3". + * + * @see getLibTSBVersionString() + */ +LIBTSB_EXTERN +const char* +getLibTSBDottedVersion(); + + +/** + * Returns the version number of this copy of libTSB as a string without + * periods. + * + * @return the libTSB version as a string: version 1.2.3 becomes "10203". + * + * @see getLibTSBDottedVersion() + */ +LIBTSB_EXTERN +const char* +getLibTSBVersionString(); + + +END_C_DECLS +LIBTSB_CPP_NAMESPACE_END + +#endif /* LIBTSB_VERSION_H */ diff --git a/deviser/pytest_files/test_other_library/test-code/tsb/tsbfwd.h b/deviser/pytest_files/test_other_library/test-code/tsb/tsbfwd.h new file mode 100644 index 000000000..2ef8f15fa --- /dev/null +++ b/deviser/pytest_files/test_other_library/test-code/tsb/tsbfwd.h @@ -0,0 +1,85 @@ +/** + * @file tsbfwd.h + * @brief Definition of tsbfwd. + * @author DEVISER + * + * + */ + + +#ifndef tsbfwd_H__ +#define tsbfwd_H__ + + +#include + +/** + * Forward declaration of all opaque C types. + * + * Declaring all types up-front avoids "redefinition of type Foo" compile + * errors and allows our combined C/C++ headers to depend minimally upon each + * other. Put another way, the type definitions below serve the same purpose as + * "class Foo;" forward declarations in C++ code. + */ + +#ifdef __cplusplus +# define CLASS_OR_STRUCT class +#else +# define CLASS_OR_STRUCT struct +#endif /* __cplusplus */ + + +LIBTSB_CPP_NAMESPACE_BEGIN + + +typedef CLASS_OR_STRUCT TSBDocument TSBDocument_t; +typedef CLASS_OR_STRUCT TSBComment TSBComment_t; +typedef CLASS_OR_STRUCT TSBBase TSBBase_t; +typedef CLASS_OR_STRUCT TSBListOf TSBListOf_t; +typedef CLASS_OR_STRUCT TSBReader TSBReader_t; +typedef CLASS_OR_STRUCT TSBWriter TSBWriter_t; +typedef CLASS_OR_STRUCT TSBNamespaces TSBNamespaces_t; +typedef CLASS_OR_STRUCT TSBError TSBError_t; +typedef CLASS_OR_STRUCT List List_t; +typedef CLASS_OR_STRUCT ListNode ListNode_t; +typedef CLASS_OR_STRUCT ExpectedAttributes ExpectedAttributes_t; + + +LIBTSB_CPP_NAMESPACE_END + + +#undef CLASS_OR_STRUCT + + +#endif /* !tsbfwd_H__ */ + + diff --git a/deviser/pytest_files/test_other_library/test_other_library.py b/deviser/pytest_files/test_other_library/test_other_library.py index 8b12f0647..520b86932 100644 --- a/deviser/pytest_files/test_other_library/test_other_library.py +++ b/deviser/pytest_files/test_other_library/test_other_library.py @@ -30,35 +30,33 @@ def teardown(): @pytest.mark.parametrize('name, num, class_name, test_case, list_of', [ - ('test_sedml', 1, 'SedModel', 'model', 'SedListOfModels'), - ('test_sedml', 0, 'SedDocument', 'document', ''), - ('test_sedml', 3, 'SedAddXML', 'xmlnode used', ''), - ('test_sedml', 26, 'SedSetValue', 'astnode used', ''), - ('test_sedml', 12, 'SedDataGenerator', 'astnode in getElementBySId bug', ''), - ('test_sedml', 33, 'SedRepeatedTask', 'attribute with different xml name', ''), - ('test_sedml', 7, 'SedSimulation', 'child element', ''), - ('test_sedml', 28, 'SedVectorRange', 'deal with vectors', ''), - ('test_sedml', 10, 'SedAbstractTask', 'catch different abstract types', - 'SedListOfTasks'), - ('test_sedml', 13, 'SedOutput', 'catch different abstract types', - 'SedListOfOutputs'), - ('combine-archive', 0, 'CaContent', 'check includes', 'CaListOfContents'), - ('combine-archive', 1, 'CaOmexManifest', 'document', ''), - ('testsbxml', 1, 'TSBComment', 'comment class', 'TSBListOfComments'), +# ('test_sedml', 1, 'SedModel', 'model', 'SedListOfModels'), +# ('test_sedml', 0, 'SedDocument', 'document', ''), +# ('test_sedml', 3, 'SedAddXML', 'xmlnode used', ''), +# ('test_sedml', 26, 'SedSetValue', 'astnode used', ''), +# ('test_sedml', 12, 'SedDataGenerator', 'astnode in getElementBySId bug', ''), +# ('test_sedml', 33, 'SedRepeatedTask', 'attribute with different xml name', ''), +# ('test_sedml', 7, 'SedSimulation', 'child element', ''), +# ('test_sedml', 28, 'SedVectorRange', 'deal with vectors', ''), +# ('test_sedml', 10, 'SedAbstractTask', 'catch different abstract types', +# 'SedListOfTasks'), +# ('test_sedml', 13, 'SedOutput', 'catch different abstract types', +# 'SedListOfOutputs'), +# ('combine-archive', 0, 'CaContent', 'check includes', 'CaListOfContents'), +# ('combine-archive', 1, 'CaOmexManifest', 'document', ''), + ('testsbxml', 1, 'TSBComment', 'comment class', 'TSBListOfComments'), ('testsbxml', 0, 'TSBDocument', 'document', ''), ]) def test_cpp(name, num, class_name, test_case, list_of): """ - Run the C++ file tests. + Based on old test_utils.run_templates() function. Run the 'template' file tests.# :param name: name of test group e.g. 'test_sedml', 'combine-archive'. - :param num: list index, so we only generate a - particular class, not all of them :param class_name: name of C++ class (and thus .cpp/.h filenames), - e.g. 'CaContent' - :param test_case: brief test description + e.g. 'SedBase' + :param test_case: brief test description, e.g. 'templates'. :param list_of: class name (and thus filenames) of any corresponding - "list of" class, e.g. 'CaListOfContents' + "list of" class, e.g. 'SedListOf' """ gv.reset() xml_filename = functions.set_up_test(name, class_name, test_case) @@ -67,69 +65,79 @@ def test_cpp(name, num, class_name, test_case, list_of): assert 0 == test_utils.compare_code_headers(class_name) assert 0 == test_utils.compare_code_impl(class_name) if len(list_of) > 0: - class_name = list_of - assert 0 == test_utils.compare_code_headers(class_name) - assert 0 == test_utils.compare_code_impl(class_name) + class_name = list_of + assert 0 == test_utils.compare_code_headers(class_name) + assert 0 == test_utils.compare_code_impl(class_name) -# @pytest.mark.parametrize('name, class_name, test_case, list_of', [ +@pytest.mark.parametrize('name, class_name, test_case, list_of', [ # # Tests from old test_utils.testCombine() # ('test_sedml', 'SedBase', 'templates', 'SedListOf'), # ('combine-archive', 'CaBase', 'templates', 'CaListOf'), -# # ('testsbxml', 'TSBBase', 'templates', 'TSBListOf'), -# ]) -# def test_templates(name, class_name, test_case, list_of): -# """ -# Based on old test_utils.run_templates() function. Run the 'template' file tests. -# -# :param name: name of test group e.g. 'test_sedml', 'combine-archive'. -# :param class_name: name of C++ class (and thus .cpp/.h filenames), -# e.g. 'SedBase' -# :param test_case: brief test description, e.g. 'templates'. -# :param list_of: class name (and thus filenames) of any corresponding -# "list of" class, e.g. 'SedListOf' -# """ -# gv.reset() -# xml_filename = functions.set_up_test(name, class_name, test_case) -# assert xml_filename is not None and xml_filename != "" -# test_utils.generate_templates(xml_filename) -# assert 0 == test_utils.compare_code_headers(class_name) -# assert 0 == test_utils.compare_code_impl(class_name) -# assert 0 == test_utils.compare_code_headers(list_of) -# assert 0 == test_utils.compare_code_impl(list_of) -# -# -# @pytest.mark.parametrize('name, class_name, test_case, prefix, lib', [ + ('testsbxml', 'TSBBase', 'templates', 'TSBListOf'), + ('testsbxml', 'TSBError', 'templates', ''), + ('testsbxml', 'TSBErrorTable', 'templates', ''), + ('testsbxml', 'TSBErrorLog', 'templates', ''), + ('testsbxml', 'TSBNamespaces', 'templates', ''), + ('testsbxml', 'TSBReader', 'templates', ''), + ('testsbxml', 'TSBVisitor', 'templates', ''), + ('testsbxml', 'TSBTypeCodes', 'templates', ''), + ('testsbxml', 'TSBTypes', 'templates', ''), + ('testsbxml', 'TSBWriter', 'templates', ''), +]) +def test_templates(name, class_name, test_case, list_of): + """ + Based on old test_utils.run_templates() function. Run the 'template' file tests. + + :param name: name of test group e.g. 'test_sedml', 'combine-archive'. + :param class_name: name of C++ class (and thus .cpp/.h filenames), + e.g. 'SedBase' + :param test_case: brief test description, e.g. 'templates'. + :param list_of: class name (and thus filenames) of any corresponding + "list of" class, e.g. 'SedListOf' + """ + gv.reset() + xml_filename = functions.set_up_test(name, class_name, test_case) + assert xml_filename is not None and xml_filename != "" + test_utils.generate_templates(xml_filename) + assert 0 == test_utils.compare_code_headers(class_name) + if not class_name.endswith('ErrorTable') and not class_name.endswith('Types'): + assert 0 == test_utils.compare_code_impl(class_name) + assert 0 == test_utils.compare_code_headers(list_of) + assert 0 == test_utils.compare_code_impl(list_of) + + +@pytest.mark.parametrize('name, class_name, test_case, prefix, lib', [ # ('test_sedml', 'SedBase', 'common', 'Sed', 'sedml'), # ('combine-archive', 'CaBase', 'common', 'Ca', 'combine'), -# # ('testsbxml', 'TSBBase', 'common', 'TSB', 'libTSB'), -# ]) -# def test_common_templates(name, class_name, test_case, prefix, lib): -# """ -# Based on test_utils.test_common_templates() function. -# Compare 'common' template files. -# -# :param name: e.g. 'test_sedml' -# :param class_name: C++ class/filenames, e.g. 'SedBase' -# :param test_case: e.g. 'common' -# :param prefix: e.g. 'Sed' -# :param lib: used for comparing lib files, e.g. 'sedml' for 'libsedml-*'. -# :return: number of failed tests. -# """ -# gv.reset() -# xml_filename = functions.set_up_test(name, class_name, test_case) -# test_utils.generate_common_templates(xml_filename) -# assert 0 == test_utils.compare_code_headers('common') -# assert 0 == test_utils.compare_code_headers('extern') -# assert 0 == test_utils.compare_code_headers('lib{0}-config'.format(lib)) -# assert 0 == test_utils.compare_code_impl('lib{0}-version'.format(lib)) -# assert 0 == test_utils.compare_code_headers('{0}OperationReturnValues'. -# format(prefix)) -# assert 0 == test_utils.compare_code_impl('{0}OperationReturnValues'. -# format(prefix)) -# assert 0 == test_utils.compare_code_cmake('lib{0}-version.h'.format(lib)) -# assert 0 == test_utils.compare_code_cmake('lib{0}-config-common.h'.format(lib)) -# assert 0 == test_utils.compare_code_cmake('lib{0}-namespace.h'.format(lib)) + ('testsbxml', 'TSBBase', 'common', 'TSB', 'tsb'), +]) +def test_common_templates(name, class_name, test_case, prefix, lib): + """ + Based on test_utils.test_common_templates() function. + Compare 'common' template files. + + :param name: e.g. 'test_sedml' + :param class_name: C++ class/filenames, e.g. 'SedBase' + :param test_case: e.g. 'common' + :param prefix: e.g. 'Sed' + :param lib: used for comparing lib files, e.g. 'sedml' for 'libsedml-*'. + :return: number of failed tests. + """ + gv.reset() + xml_filename = functions.set_up_test(name, class_name, test_case) + test_utils.generate_common_templates(xml_filename) + assert 0 == test_utils.compare_code_headers('common') + assert 0 == test_utils.compare_code_headers('extern') + assert 0 == test_utils.compare_code_headers('lib{0}-config'.format(lib)) + assert 0 == test_utils.compare_code_impl('lib{0}-version'.format(lib)) + assert 0 == test_utils.compare_code_headers('{0}OperationReturnValues'. + format(prefix)) + assert 0 == test_utils.compare_code_impl('{0}OperationReturnValues'. + format(prefix)) + assert 0 == test_utils.compare_code_cmake('lib{0}-version.h'.format(lib)) + assert 0 == test_utils.compare_code_cmake('lib{0}-config-common.h'.format(lib)) + assert 0 == test_utils.compare_code_cmake('lib{0}-namespace.h'.format(lib)) # # # @pytest.mark.parametrize('name, class_name, test_case', [ @@ -196,62 +204,62 @@ def test_cpp(name, num, class_name, test_case, list_of): # binding, "") # # -# @pytest.mark.parametrize('name, class_name', [ +@pytest.mark.parametrize('name, class_name', [ # # ('test_sedml', 'libsedml'), # ('combine-archive', 'libcombine'), -# ('testsbxml', 'libTSB') -# ]) -# def test_cmake(name, class_name): -# """ -# Based on old test_cmake() function in run_other_library_tests.py -# Generate and compare CMake files. -# -# TODO the following need more details: -# -# :param name: name of test, e.g. 'test_sedml' or 'combine-archive'. -# :param class_name: e.g. 'libsedml' or 'libcombine' -# """ -# gv.reset() -# xml_filename = functions.set_up_test(name, class_name, "cmake") -# test_utils.generate_cmake(xml_filename, "cmake") -# assert 0 == test_utils.compare_cmake_file('') -# assert 0 == test_utils.compare_cmake_file('src') -# assert 0 == test_utils.compare_cmake_file('src/bindings') -# assert 0 == test_utils.compare_cmake_file('src/{0}'.format(gv.language)) -# -# -# @pytest.mark.parametrize('name, class_name, test_case', [ -# ('test_sedml', 'libsedml', 'global files'), -# ]) -# def test_global(name, class_name, test_case): -# """ -# Based on old test_utils.test_global() function. -# Generate and compare 'global' files, e.g. VERSION.txt, README.md. -# -# :param name: test file stub, e.g. 'test_sedml' for test_sedml.xml -# :param class_name: test class e.g. 'libsedml' -# :param test_case: brief description of test, e.g. 'global files' -# """ -# xml_filename = functions.set_up_test(name, class_name, test_case) -# test_utils.generate_global(xml_filename) -# assert 0 == test_utils.compare_code_txt('VERSION') -# assert 0 == test_utils.compare_code_txt('README', '.md') -# -# -# @pytest.mark.parametrize('name, class_name, test_case', [ -# ('test_sedml', 'sedmlfwd', 'forward declarations'), -# ]) -# def test_forward(name, class_name, test_case): -# """ -# Based on old run_forward() function. -# Run 'forward declaration' tests. -# -# :param name: stub of XML filename, e.g. 'test_sedml' -# for file test_sedml.xml. -# :param class_name: test class, e.g. 'sedmlfwd' -# :param test_case: brief test description, e.g. 'forward declarations' -# """ -# gv.reset() -# xml_filename = functions.set_up_test(name, class_name, test_case) -# test_utils.generate_forward(xml_filename) -# assert 0 == test_utils.compare_code_headers(class_name) + ('testsbxml', 'libTSB') +]) +def test_cmake(name, class_name): + """ + Based on old test_cmake() function in run_other_library_tests.py + Generate and compare CMake files. + + TODO the following need more details: + + :param name: name of test, e.g. 'test_sedml' or 'combine-archive'. + :param class_name: e.g. 'libsedml' or 'libcombine' + """ + gv.reset() + xml_filename = functions.set_up_test(name, class_name, "cmake") + test_utils.generate_cmake(xml_filename, "cmake") + assert 0 == test_utils.compare_cmake_file('') + assert 0 == test_utils.compare_cmake_file('src') + assert 0 == test_utils.compare_cmake_file('src/bindings') + assert 0 == test_utils.compare_cmake_file('src/{0}'.format(gv.language)) + + +@pytest.mark.parametrize('name, class_name, test_case', [ + ('testsbxml', 'libTSB', 'global files'), +]) +def test_global(name, class_name, test_case): + """ + Based on old test_utils.test_global() function. + Generate and compare 'global' files, e.g. VERSION.txt, README.md. + + :param name: test file stub, e.g. 'test_sedml' for test_sedml.xml + :param class_name: test class e.g. 'libsedml' + :param test_case: brief description of test, e.g. 'global files' + """ + xml_filename = functions.set_up_test(name, class_name, test_case) + test_utils.generate_global(xml_filename) + assert 0 == test_utils.compare_code_txt('VERSION') + assert 0 == test_utils.compare_code_txt('README', '.md') + + +@pytest.mark.parametrize('name, class_name, test_case', [ + ('testsbxml', 'tsbfwd', 'forward declarations'), +]) +def test_forward(name, class_name, test_case): + """ + Based on old run_forward() function. + Run 'forward declaration' tests. + + :param name: stub of XML filename, e.g. 'test_sedml' + for file test_sedml.xml. + :param class_name: test class, e.g. 'sedmlfwd' + :param test_case: brief test description, e.g. 'forward declarations' + """ + gv.reset() + xml_filename = functions.set_up_test(name, class_name, test_case) + test_utils.generate_forward(xml_filename) + assert 0 == test_utils.compare_code_headers(class_name) diff --git a/deviser/pytest_files/test_other_library/test_utils.py b/deviser/pytest_files/test_other_library/test_utils.py index 09c8be7e7..d638b434d 100644 --- a/deviser/pytest_files/test_other_library/test_utils.py +++ b/deviser/pytest_files/test_other_library/test_utils.py @@ -245,10 +245,10 @@ def compare_code(class_name, end): return compare_files(correct_file, temp_file) def compare_code_headers(class_name): - return compare_code(class_name, ".h") + return compare_code(class_name, ".h") if not class_name == '' else 0 def compare_code_impl(class_name): - return compare_code(class_name, ".cpp") + return compare_code(class_name, ".cpp") if not class_name == '' else 0 def compare_code_cmake(class_name): return compare_code(class_name, ".cmake") diff --git a/deviser/pytest_files/test_tex/test-tex/testsbxml/apdx-validation.tex b/deviser/pytest_files/test_tex/test-tex/testsbxml/apdx-validation.tex new file mode 100644 index 000000000..66db31607 --- /dev/null +++ b/deviser/pytest_files/test_tex/test-tex/testsbxml/apdx-validation.tex @@ -0,0 +1,186 @@ +% -*- TeX-master: "main"; fill-column: 72 -*- + +\section{Validation of SBML documents} +\label{apdx-validation} + +\subsection{Validation and consistency rules} +\label{validation-rules} + +This section summarizes all the conditions that must (or in some cases, +at least \emph{should}) be true of an SBML Level~1 Version~1 model that +uses the \TestTSBXMLLibraryPackage. We use the same conventions as are +used in the SBML Level~1 Version~1 Core specification document. In +particular, there are different degrees of rule strictness. Formally, +the differences are expressed in the statement of a rule: either a rule +states that a condition \emph{must} be true, or a rule states that it +\emph{should} be true. Rules of the former kind are strict SBML +validation rules---a model encoded in SBML must conform to all of them +in order to be considered valid. Rules of the latter kind are +consistency rules. To help highlight these differences, we use the +following three symbols next to the rule numbers: + +\begin{description} + +\item[\hspace*{6.5pt}\vSymbol\vsp] A \vSymbolName indicates a +\emph{requirement} for SBML conformance. If a model does not follow this +rule, it does not conform to the \TestTSBXMLLibraryPackage +specification. (Mnemonic intention behind the choice of symbol: ``This +must be checked.'') + +\item[\hspace*{6.5pt}\cSymbol\csp] A \cSymbolName indicates a +\emph{recommendation} for model consistency. If a model does not follow +this rule, it is not considered strictly invalid as far as the +\TestTSBXMLLibraryPackage specification is concerned; however, it +indicates that the model contains a physical or conceptual +inconsistency. (Mnemonic intention behind the choice of symbol: ``This +is a cause for warning.'') + +\item[\hspace*{6.5pt}\mSymbol\msp] A \mSymbolName indicates a strong +recommendation for good modeling practice. This rule is not strictly a +matter of SBML encoding, but the recommendation comes from logical +reasoning. As in the previous case, if a model does not follow this +rule, it is not strictly considered an invalid SBML encoding. (Mnemonic +intention behind the choice of symbol: ``You're a star if you heed +this.'') + +\end{description} + +The validation rules listed in the following subsections are all stated +or implied in the rest of this specification document. They are +enumerated here for convenience. Unless explicitly stated, all +validation rules concern objects and attributes specifically defined in +the \TestTSBXMLLibraryPackage package. + +For \notice convenience and brevity, we use the shorthand +``\token{:\-x}'' to stand for an attribute or element name \token{x} in +the namespace for the \TestTSBXMLLibraryPackage package, using the +namespace prefix \token{}. In reality, the prefix string may be +different from the literal ``\token{}'' used here (and indeed, it can be +any valid XML namespace prefix that the modeler or software chooses). We +use ``\token{:\-x}'' because it is shorter than to write a full +explanation everywhere we refer to an attribute or element in the +\TestTSBXMLLibraryPackage namespace. + +\subsubsection*{General rules about this package} + +\validRule{tsb-10101}{To conform to the \TestTSBXMLLibrary specification +for TSB Level~1 Version~1, an TSB document must declare +\uri{http://testsbxml.org/l1v1} as the XMLNamespace to use for elements +of this package. (Reference: TSB Level~1 Specification for Test TSB XML +Library, Version~1 \sec{xml-namespace}.)} + +\validRule{tsb-10102}{Wherever they appear in a TSB document, elements +and attributes from the \TestTSBXMLLibrary must use the +\uri{http://testsbxml.org/l1v1} namespace, declaring so either +explicitly or implicitly. (Reference: TSB Level~1 Specification for Test +TSB XML Library, Version~1 \sec{xml-namespace}.)} + +\subsubsection*{General rules about identifiers} + +\validRule{tsb-10201}{The value of a \token{metaid} must conform to the +syntax of the XML Type ID (Reference: metaid)} + +\subsubsection*{General rules for \TestAnnotation elements} + +\validRule{tsb-10301}{Every top-level XML element within an +\TestAnnotation object must have an XML namespace declared. (Reference: +TSB Level~1 Specification for Test TSB XML Library, Version~1 +\sec{annotation-use}.)} + +\validRule{tsb-10302}{A given XML namespace cannot be the namespace of +more than one top-levelelement within a given \TestAnnotation object. +(Reference: TSB Level~1 Specification for Test TSB XML Library, +Version~1 \sec{annotation-use}.)} + +\validRule{tsb-10303}{A given TSB element may contain at most one +\TestAnnotation subobject. (Reference: TSB Level~1 Specification for +Test TSB XML Library, Version~1 \sec{annotation-use}.)} + +\subsubsection*{General rules for \notes elements} + +\validRule{tsb-10401}{The contents of a \Notes object must be explicitly +placed in the XHTML XML namespace. (Reference: TSB Level~1 Specification +for Test TSB XML Library, Version~1 \sec{notes}.)} + +\validRule{tsb-10402}{The contents of a \Notes object must not contain +an XML declaration, \ie a string of the form \val{} or similar. (Reference: TSB Level~1 Specification +for Test TSB XML Library, Version~1 \sec{notes}.)} + +\validRule{tsb-10403}{The content of a \Notes object must not contain an +XML DOCTYPE declaration, \ie a string beginning with the characters +\val{ - + diff --git a/deviser/spec_files/TexMacrosFile.py b/deviser/spec_files/TexMacrosFile.py index a6e298e0a..554bc69ba 100644 --- a/deviser/spec_files/TexMacrosFile.py +++ b/deviser/spec_files/TexMacrosFile.py @@ -41,113 +41,160 @@ import re from ..base_files import BaseTexFile -from ..util import strFunctions +from ..util import global_variables, strFunctions class TexMacrosFile(BaseTexFile.BaseTexFile): """Class for the definition of class name macros in LaTeX""" def __init__(self, object_desc): - # derived members for description - self.brief_description = 'Macros definition for specification' - - BaseTexFile.BaseTexFile.__init__(self, 'macros', 'tex', object_desc) - - # self.full_pkg_command = '\\{}Package'.format(self.fulltexname) - # self.brief_pkg_command = '\\{}'.format(self.upper_package) - - self.core_classes = ['Model', 'Compartment', 'Species', 'Parameter', - 'Rule', 'InitialAssignment', 'Reaction', 'Event', - 'Constraint', 'SpeciesReference', - 'EventAssignment', - 'KineticLaw', 'LocalParameter'] + self.brief_description = "Macros definition for specification" + + BaseTexFile.BaseTexFile.__init__(self, "macros", "tex", object_desc) + + self.core_classes = [ + "Model", + "Compartment", + "Species", + "Parameter", + "Rule", + "InitialAssignment", + "Reaction", + "Event", + "Constraint", + "SpeciesReference", + "EventAssignment", + "KineticLaw", + "LocalParameter", + ] ######################################################################## # Write the command for each class def write_macro_for_class(self, sbml_class): - self.write_text_line('\\newcommand{0}\\{1}{2}{0}\\defRef{0}{4}{2}' - '{0}{3}{2}{2}' - .format(self.start_b, sbml_class['texname'], - self.end_b, - strFunctions.make_tex_class(sbml_class['texname']), - sbml_class['name'])) + self.write_text_line( + "\\newcommand{0}\\{1}{2}{0}\\defRef{0}{4}{2}" + "{0}{3}{2}{2}".format( + self.start_b, + sbml_class["texname"], + self.end_b, + strFunctions.make_tex_class(sbml_class["texname"]), + sbml_class["name"], + ) + ) # Write commands for each ListOf class def write_macro_for_listof(self, sbml_class): - if sbml_class['hasListOf']: - if 'lo_elementName' in sbml_class \ - and sbml_class['lo_elementName'] != '': - lo_name = strFunctions.upper_first( - sbml_class['lo_elementName']) + if sbml_class["hasListOf"]: + if "lo_elementName" in sbml_class and sbml_class["lo_elementName"] != "": + lo_name = strFunctions.upper_first(sbml_class["lo_elementName"]) + elif global_variables.language != "sbml": + lo_name = strFunctions.cap_list_of_name(sbml_class["name"], False) else: - lo_name = strFunctions.cap_list_of_name(sbml_class['name']) - self.write_text_line('\\newcommand{0}\\{1}{2}{0}\\defRef{0}{1}{2}' - '{0}{3}{2}{2}' - .format(self.start_b, lo_name, self.end_b, - strFunctions.make_tex_class(lo_name))) + lo_name = strFunctions.cap_list_of_name(sbml_class["name"]) + self.write_text_line( + "\\newcommand{0}\\{1}{2}{0}\\defRef{0}{1}{2}" + "{0}{3}{2}{2}".format( + self.start_b, + lo_name, + self.end_b, + strFunctions.make_tex_class(lo_name), + ) + ) # hack for render - if sbml_class['name'] == 'GradientBase': - self.write_text_line('\\newcommand{0}\\{4}{2}{0}\\defRef{0}{1}{2}' - '{0}{3}{2}{2}' - .format(self.start_b, lo_name, self.end_b, - strFunctions.make_tex_class(lo_name), - 'ListOfGradientBases')) - elif sbml_class['name'] == 'RenderPoint': - self.write_text_line('\\newcommand{0}\\{4}{2}{0}\\defRef{0}{1}{2}' - '{0}{3}{2}{2}' - .format(self.start_b, lo_name, self.end_b, - strFunctions.make_tex_class(lo_name), - 'ListOfRenderPoints')) + if sbml_class["name"] == "GradientBase": + self.write_text_line( + "\\newcommand{0}\\{4}{2}{0}\\defRef{0}{1}{2}" + "{0}{3}{2}{2}".format( + self.start_b, + lo_name, + self.end_b, + strFunctions.make_tex_class(lo_name), + "ListOfGradientBases", + ) + ) + elif sbml_class["name"] == "RenderPoint": + self.write_text_line( + "\\newcommand{0}\\{4}{2}{0}\\defRef{0}{1}{2}" + "{0}{3}{2}{2}".format( + self.start_b, + lo_name, + self.end_b, + strFunctions.make_tex_class(lo_name), + "ListOfRenderPoints", + ) + ) # Write commands for each primitive type def write_macro_for_enum(self, enum): # check for underscores - cmd_name = re.sub('_t', 't', enum['name']) - self.write_text_line('\\newcommand{0}\\{1}{2}{0}\\defRef{0}{3}{2}' - '{0}{4}{2}{2}' - .format(self.start_b, cmd_name, - self.end_b, enum['name'], - 'primitive-types')) + cmd_name = re.sub("_t", "t", enum["name"]) + self.write_text_line( + "\\newcommand{0}\\{1}{2}{0}\\defRef{0}{3}{2}" + "{0}{4}{2}{2}".format( + self.start_b, cmd_name, self.end_b, enum["name"], "primitive-types" + ) + ) # Write commands for each plugin def write_macro_for_plugin(self, plugin): - if plugin['sbase'] not in self.core_classes: - self.write_text_line('\\newcommand{0}\\{1}{2}{0}\\defRef{0}{4}{2}' - '{0}{3}{2}{2}' - .format(self.start_b, plugin['sbase'], - self.end_b, - strFunctions.make_tex_class(plugin['sbase']), - plugin['sbase'])) + if plugin["sbase"] not in self.core_classes: + self.write_text_line( + "\\newcommand{0}\\{1}{2}{0}\\defRef{0}{4}{2}" + "{0}{3}{2}{2}".format( + self.start_b, + plugin["sbase"], + self.end_b, + strFunctions.make_tex_class(plugin["sbase"]), + plugin["sbase"], + ) + ) # Write general commands def write_general_commands(self): - self.write_comment_line('\\newcommand{\\fixttspace}{\\hspace*{1pt}}') + self.write_comment_line("\\newcommand{\\fixttspace}{\\hspace*{1pt}}") - self.write_text_line('\\newcommand{0}\\const{1}[1]{0}\\texttt{0} #1{1}{1}' - .format(self.start_b, self.end_b)) + self.write_text_line( + "\\newcommand{0}\\const{1}[1]{0}\\texttt{0} #1{1}{1}".format( + self.start_b, self.end_b + ) + ) self.skip_line() - self.write_text_line('\\newcommand{0}\\sbmlthreecore{1}{0}SBML Level~{2} ' - 'Version~{3} Core\\xspace{1}'.format(self.start_b, - self.end_b, - self.level, - self.version)) - self.write_text_line('\\newcommand{0}{1}{2}{0}\\textsf{0}{3}' - '{2} package\\xspace{2}'.format(self.start_b, - self.full_pkg_command, - self.end_b, - self.fullname)) - self.write_text_line('\\newcommand{0}{1}{2}{0}\\textsf{0}{3}{2}' - '\\xspace{2}' - .format(self.start_b, - self.brief_pkg_command, - self.end_b, - self.fullname)) + if global_variables.language == "sbml": + self.write_text_line( + "\\newcommand{0}\\sbmlthreecore{1}{0}SBML Level~{2} " + "Version~{3} Core\\xspace{1}".format( + self.start_b, self.end_b, self.level, self.version + ) + ) + self.write_text_line( + "\\newcommand{0}{1}{2}{0}\\textsf{0}{3}" + "{2} package\\xspace{2}".format( + self.start_b, self.full_pkg_command, self.end_b, self.fullname + ) + ) + else: + self.write_text_line( + "\\newcommand{0}{1}{2}{0}\\textsf{0}{3}" + "{2}\\xspace{2}".format( + self.start_b, self.full_pkg_command, self.end_b, self.fullname + ) + ) + + self.write_text_line( + "\\newcommand{0}{1}{2}{0}\\textsf{0}{3}{2}" + "\\xspace{2}".format( + self.start_b, self.brief_pkg_command, self.end_b, self.fullname + ) + ) self.skip_line() - self.write_text_line('\\newcommand{0}\\TODO{1}[1]{0}\\colorbox{0}blue{1}' - '{0}\\textcolor{0}white{1}{0}TODO: #1{1}{1}{1}' - .format(self.start_b, self.end_b)) + self.write_text_line( + "\\newcommand{0}\\TODO{1}[1]{0}\\colorbox{0}blue{1}" + "{0}\\textcolor{0}white{1}{0}TODO: #1{1}{1}{1}".format( + self.start_b, self.end_b + ) + ) self.skip_line() ######################################################################### @@ -157,23 +204,23 @@ def write_file(self): BaseTexFile.BaseTexFile.write_file(self) self.write_general_commands() self.skip_line() - self.write_comment_line('commands for classes') + self.write_comment_line("commands for classes") for i in range(0, len(self.sbml_classes)): # hack for render - if self.sbml_classes[i]['name'] != "RelAbsVector": + if self.sbml_classes[i]["name"] != "RelAbsVector": self.write_macro_for_class(self.sbml_classes[i]) self.skip_line() - self.write_comment_line('commands for listOfClasses') + self.write_comment_line("commands for listOfClasses") for i in range(0, len(self.sbml_classes)): self.write_macro_for_listof(self.sbml_classes[i]) self.skip_line() - self.write_comment_line('commands for types') + self.write_comment_line("commands for types") for i in range(0, len(self.enums)): self.write_macro_for_enum(self.enums[i]) for i in range(0, len(self.prim_class)): self.write_macro_for_enum(self.prim_class[i]) self.skip_line() - self.write_comment_line('commands for plugins') + self.write_comment_line("commands for plugins") for i in range(0, len(self.plugins)): self.write_macro_for_plugin(self.plugins[i]) diff --git a/deviser/spec_files/TexValidationRulesFile.py b/deviser/spec_files/TexValidationRulesFile.py index 632cd3efb..9dd5e690b 100644 --- a/deviser/spec_files/TexValidationRulesFile.py +++ b/deviser/spec_files/TexValidationRulesFile.py @@ -41,6 +41,7 @@ import re from ..base_files import BaseTexFile +from ..util import global_variables, strFunctions from ..validation import ValidationRulesForClass from ..validation import ValidationRulesForPlugin from ..validation import ValidationRulesGeneral @@ -59,13 +60,21 @@ def __init__(self, object_desc): BaseTexFile.BaseTexFile.__init__(self, 'apdx-validation', 'tex', object_desc) - self.full_pkg_command = '\\{0}Package'.format(self.fulltexname) - self.brief_pkg_command = '\\{0}'.format(self.upper_package) - - self.pkg_ref = 'SBML Level~{0} Specification for {1}, ' \ - 'Version~{2}'.format(self.level, - self.fullname, self.pkg_version) - self.reqd_status = object_desc['required'] + if global_variables.is_sbml: + self.pkg_ref = 'SBML Level~{0} Specification for {1}, ' \ + 'Version~{2}'.format(self.level, + self.fullname, self.pkg_version) + self.full_pkg_command = '\\{0}Package'.format(self.fulltexname) + self.brief_pkg_command = '\\{0}'.format(self.upper_package) + self.reqd_status = object_desc['required'] + else: + self.pkg_ref = '{3} Level~{0} Specification for {1}, ' \ + 'Version~{2}'.format(self.level, + self.fullname, self.version, + global_variables.language.upper()) + self.full_pkg_command = '\\{0}'.format(self.fulltexname) + self.brief_pkg_command = '\\{0}'.format(self.upper_package) + self.reqd_status = False ######################################################################## @@ -86,11 +95,18 @@ def write_rule(self, rule, name='', texname=''): else: severity = self.consist - self.write_text_line('{0}{1}-{2}{3}{4}{5} (Reference: {6}){7}' - .format(severity, self.package, - rule['number']-self.offset, - self.end_b, self.start_b, text, - ref, self.end_b)) + if global_variables.is_sbml: + self.write_text_line('{0}{1}-{2}{3}{4}{5} (Reference: {6}){7}' + .format(severity, self.package, + rule['number']-self.offset, + self.end_b, self.start_b, text, + ref, self.end_b)) + else: + self.write_text_line('{0}{1}-{2}{3}{4}{5} (Reference: {6}){7}' + .format(severity, global_variables.language, + rule['number'], + self.end_b, self.start_b, text, + ref, self.end_b)) #################################################################### @@ -105,7 +121,37 @@ def write_identifier_rules(self, rules): self.write_text_line( '\subsubsection*{General rules about identifiers}') self.skip_line() - for i in range(3, 5): + if global_variables.is_sbml: + for i in range(3, 5): + self.write_rule(rules[i]) + self.skip_line() + else: + self.write_rule(rules[3]) + self.skip_line() + + def write_rules_for_annotation(self, rules): + """ + Write the annotation rules for another library + :param rules: + :return: + """ + self.write_text_line( + '\subsubsection*{0}General rules for \\{1} elements{2}'.format('{', global_variables.annot_element, '}')) + self.skip_line() + for i in range(4, 7): + self.write_rule(rules[i]) + self.skip_line() + + def write_rules_for_notes(self, rules): + """ + Write the notes rules for another library + :param rules: + :return: + """ + self.write_text_line( + '\subsubsection*{General rules for \\notes elements}') + self.skip_line() + for i in range(7, 11): self.write_rule(rules[i]) self.skip_line() @@ -190,13 +236,17 @@ def write_file(self): rules = ValidationRulesGeneral.ValidationRulesGeneral( self.fullname, self.offset, self.package, self.pkg_ref, self.level, self.version, - self.pkg_version, self.reqd_status) + self.pkg_version, self.reqd_status, self.full_pkg_command) rules.determine_rules() self.write_general_rules(rules.rules) self.write_identifier_rules(rules.rules) - self.write_to_do('ANY LIST OF ELEMENTS THAT HAVE ATTRIBUTES') - self.write_extended_sbml_rules(rules.rules) - number = self.offset + 20200 + if global_variables.is_sbml: + self.write_to_do('ANY LIST OF ELEMENTS THAT HAVE ATTRIBUTES') + self.write_extended_sbml_rules(rules.rules) + else: + self.write_rules_for_annotation(rules.rules) + self.write_rules_for_notes(rules.rules) + number = self.offset + 20200 if global_variables.is_sbml else 20100 for i in range(0, len(self.plugins)): rules = ValidationRulesForPlugin.ValidationRulesForPlugin( self.plugins[i], self.fullname, number, @@ -218,6 +268,19 @@ def write_file(self): self.sbml_classes[i]['texname'], rules.rules) self.skip_line() + if not global_variables.is_sbml: + for att in self.sbml_classes[i]['attribs']: + if att['type'] == 'lo_element': + rules.rules = [] + number += 100 + rules.number = number + + rules.add_lo_rules() + self.write_rules_for_class(strFunctions.cap_list_of_name_no_prefix(att['name']), + strFunctions.cap_list_of_name_no_prefix(att['texname']), + rules.rules) + self.skip_line() + number += 100 # override diff --git a/deviser/util/generateCode.py b/deviser/util/generateCode.py index 2d8550af3..e3a935492 100644 --- a/deviser/util/generateCode.py +++ b/deviser/util/generateCode.py @@ -358,7 +358,7 @@ def generate_other_library_code_files(name, ob): working_class['document'] = True all_files = CppFiles.CppFiles(working_class, True) all_files.write_files() - base_files = OtherLibraryFiles(prefix, ob['baseElements'], True) + base_files = OtherLibraryFiles.OtherLibraryFiles(prefix, ob['baseElements'], True) base_files.write_files() os.chdir(this_dir) diff --git a/deviser/util/global_variables.py b/deviser/util/global_variables.py index 023f0614a..a952fd551 100644 --- a/deviser/util/global_variables.py +++ b/deviser/util/global_variables.py @@ -59,6 +59,8 @@ global language language = 'sbml' +global is_sbml +is_sbml = True global baseClass baseClass = 'SBase' global std_base @@ -192,6 +194,9 @@ def set_globals(lang, base, doc, prfix, lib, is_pack, pkg_prefix, use_name_1=True, ast=False, xml=False, top_name=''): global language language = lang + if language != 'sbml': + global is_sbml + is_sbml = False global namespaces global has_level_version diff --git a/deviser/util/templates/README.md b/deviser/util/templates/README.md index 8df04fec2..022133acd 100644 --- a/deviser/util/templates/README.md +++ b/deviser/util/templates/README.md @@ -2,10 +2,10 @@ ## Dependencies -This library requires libSBML to be present, as its XML parsing layer will be used. for that either expat, xerces-c or libXML2 needs to be available. +This library requires either liblx or libSBML to be present, as its XML parsing layer will be used. For that either expat, xerces-c or libXML2 needs to be available. ## Building -This library uses [CMake](http://cmake.org) to build the library, so from an initial checkout all you would need todo is to run: +This library uses [CMake](http://cmake.org) to build the library, so from an initial checkout all you would need to do is to run: mkdir build @@ -14,7 +14,18 @@ This library uses [CMake](http://cmake.org) to build the library, so from an ini make make install -Should libSBML be installed in a default location it will be found automatically. Note that you do need to list the xml libraries that libSBML was linked against. In most cases libSBML is compiled against libXML and have compression enabled, so your `EXTRA_LIBS` would be: +OR + + + mkdir build + cd build + cmake -DLIBLX_LIBRARY=< path to liblx lib> -DLIBLX_INCLUDE_DIR=< path to includes > ... -DEXTRA_LIBS= < comma separated list of xml libraries> + make + make install + + + +Should libSBML/liblx be installed in a default location it will be found automatically. Note that you do need to list the xml libraries that libSBML was linked against. In most cases libSBML is compiled against libXML and have compression enabled, so your `EXTRA_LIBS` would be: EXTRA_LIBS=xml2;bz2;z;iconv @@ -22,7 +33,7 @@ note the semicolon denoting the listing of several libraries. Of course you coul EXTRA_LIBS=D:/dependencies/lib/expat.lib -for linking against `expat` and indicating, that libSBML was compiled without compression. +for linking against `expat` and indicating, that libSBML/liblx was compiled without compression. ## License diff --git a/deviser/validation/ValidationRulesForClass.py b/deviser/validation/ValidationRulesForClass.py index e566879c8..4acb29ed5 100644 --- a/deviser/validation/ValidationRulesForClass.py +++ b/deviser/validation/ValidationRulesForClass.py @@ -41,26 +41,32 @@ from ..util import strFunctions, query, global_variables -class ValidationRulesForClass(): +class ValidationRulesForClass: """Class for creating the validation rules for an object""" def __init__(self, object_desc, spec_name, number, package, pkg_ref): # members from object + remove_doc_prefix = True if global_variables.is_sbml else False self.name = strFunctions.remove_prefix(object_desc['name'], - remove_doc_prefix=True) + remove_doc_prefix) self.fullname = spec_name self.number = number self.package = package.lower() self.pkg_ref = pkg_ref - self.up_package = strFunctions.upper_first(self.package) + self.level = object_desc['root']['base_level'] + self.version = object_desc['root']['base_version'] # useful repeated text strings self.valid = '\\validRule{' self.start_b = '{' self.end_b = '}' - self.lower_name = strFunctions.lower_first(strFunctions.remove_prefix(self.name)) - self.formatted_name = r'\{0}'.format(strFunctions.remove_prefix(self.name)) + if global_variables.is_sbml: + self.lower_name = strFunctions.lower_first(strFunctions.remove_prefix(self.name)) + self.formatted_name = r'\{0}'.format(strFunctions.remove_prefix(self.name)) + else: + self.lower_name = strFunctions.lower_first(self.name) + self.formatted_name = r'\{0}'.format(self.name) self.indef = strFunctions.get_indefinite(self.lower_name) self.indef_u = strFunctions.upper_first(self.indef) @@ -77,6 +83,14 @@ def __init__(self, object_desc, spec_name, number, package, pkg_ref): self.parse_elements(self, object_desc['attribs'], object_desc['root']) self.rules = [] self.tc = 'TBC' + # constants for rules + if global_variables.is_sbml: + self.up_package = strFunctions.upper_first(self.package) + self.lib_ref = 'L3V1 {0} V1 Section 3.1'.format(self.up_package) + else: + self.up_package = self.package.upper() + self.lib_ref = '{0} L{1}V{2} Section '.format(self.up_package, self.level, self.version) + ######################################################################## @@ -84,11 +98,12 @@ def __init__(self, object_desc, spec_name, number, package, pkg_ref): def determine_rules(self): # write rules increasing the number - self.number += 1 - self.rules.append(self.write_core_attribute_rule(self)) + if global_variables.is_sbml: + self.number += 1 + self.rules.append(self.write_core_attribute_rule(self)) - self.number += 1 - self.rules.append(self.write_core_subobject_rule(self)) + self.number += 1 + self.rules.append(self.write_core_subobject_rule(self)) self.number += 1 rule = self.write_package_attribute_rule(self) @@ -104,10 +119,15 @@ def determine_rules(self): self.add_rule(rule) for i in range(0, len(self.opt_att)): + if not global_variables.is_sbml and self.opt_att[i]['name'] == 'metaid': + continue self.number += 1 rule = self.write_attribute_type_rule(self, self.opt_att[i]) self.add_rule(rule) + if global_variables.is_sbml: + self.add_lo_rules() + def add_lo_rules(self): if len(self.opt_child_lo_elem) > 0: self.number += 1 rule = self.write_optional_lo_rule() @@ -115,8 +135,7 @@ def determine_rules(self): for i in range(0, len(self.opt_child_lo_elem)): self.number += 1 - rule = \ - self.write_core_subobject_rule(self, self.opt_child_lo_elem[i]) + rule = self.write_core_subobject_rule(self, self.opt_child_lo_elem[i]) self.add_rule(rule) if len(self.reqd_child_lo_elem) > 0: @@ -175,9 +194,9 @@ def determine_rules(self): self.write_lochild_attribute_rule(self.lo_reqd_att[i], lo_info) self.add_rule(rule) if rule and 'attributes' in lo_info[0]: - for i in range(0, len(lo_info[0]['attributes'])): + for j in range(0, len(lo_info[0]['attributes'])): self.number += 1 - rule = self.write_attribute_type_rule(self, lo_info[0]['attributes'][i], lo_info[0]) + rule = self.write_attribute_type_rule(self, lo_info[0]['attributes'][j], lo_info[0]) self.add_rule(rule) lo_info = [] @@ -187,9 +206,9 @@ def determine_rules(self): self.write_lochild_attribute_rule(self.lo_opt_att[i], lo_info) self.add_rule(rule) if rule and 'attributes' in lo_info[0]: - for i in range(0, len(lo_info[0]['attributes'])): + for j in range(0, len(lo_info[0]['attributes'])): self.number += 1 - rule = self.write_attribute_type_rule(self, lo_info[0]['attributes'][i], lo_info[0]) + rule = self.write_attribute_type_rule(self, lo_info[0]['attributes'][j], lo_info[0]) self.add_rule(rule) def add_rule(self, rule): @@ -215,7 +234,7 @@ def write_attribute_type_rule(self, attribute, lo=None): refname = self.name abbrev = self.name att_type = attribute['type'] - [att_name_no_hyphen, unused] = strFunctions.remove_hyphens(attribute['name']) + [att_name_no_hyphen, __] = strFunctions.remove_hyphens(attribute['name']) att_name = strFunctions.upper_first(att_name_no_hyphen) name = strFunctions.wrap_token(attribute['texname'], self.package) rule_type = 'String' @@ -335,89 +354,159 @@ def write_attribute_type_rule(self, attribute, lo=None): rule_type) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref, + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref, 'object': refname, 'attrib': att_name, 'attrib_type': att_type}) @staticmethod # write core attribute rule def write_core_attribute_rule(self, lo_child=None): - if lo_child is None: - text = '{0} {1} object may have the optional SBML Level~3 ' \ - 'Core attributes {2} and {3}. No other attributes from the ' \ - 'SBML Level~3 Core namespaces are permitted on {4} {1}.'\ - .format(self.indef_u, self.formatted_name, - strFunctions.wrap_token('metaid'), - strFunctions.wrap_token('sboTerm'), self.indef) - ref = 'SBML Level~3 Version~1 Core, Section~3.2.' - sev = 'ERROR' - lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) - tc = '{0}{1}AllowedCoreAttributes'.format(self.up_package, - self.name) - short = 'Core attributes allowed on <{0}>.'.format(self.lower_name) - lo = False + if global_variables.is_sbml: + if lo_child is None: + text = '{0} {1} object may have the optional SBML Level~3 ' \ + 'Core attributes {2} and {3}. No other attributes from the ' \ + 'SBML Level~3 Core namespaces are permitted on {4} {1}.'\ + .format(self.indef_u, self.formatted_name, + strFunctions.wrap_token('metaid'), + strFunctions.wrap_token('sboTerm'), self.indef) + ref = 'SBML Level~3 Version~1 Core, Section~3.2.' + sev = 'ERROR' + lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) + tc = '{0}{1}AllowedCoreAttributes'.format(self.up_package, + self.name) + short = 'Core attributes allowed on <{0}>.'.format(self.lower_name) + lo = False + else: + loname = strFunctions.get_tex_element_name(lo_child, leave_pkg_prefix=False) + temp = strFunctions.remove_prefix(lo_child['element']) + lo_name = loname[7:] #strFunctions.plural(temp) + text = 'A {0} object may have the optional SBML Level~3 ' \ + 'Core attributes {1} and {2}. No other attributes from the ' \ + 'SBML Level~3 Core namespaces are permitted on a {0} object.'\ + .format(strFunctions.get_tex_element_name(lo_child, False), + strFunctions.wrap_token('metaid'), + strFunctions.wrap_token('sboTerm')) + sec_name = 'listof' + lo_name.lower() + ref = '{0}, {1}.'\ + .format(self.pkg_ref, strFunctions.wrap_section(sec_name)) + sev = 'ERROR' + lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) + tc = '{0}{1}LO{2}AllowedCoreAttributes'.format(self.up_package, + self.name, lo_name) + lo = True + short = 'Core attributes allowed on .'.format(lo_name) else: - loname = strFunctions.get_tex_element_name(lo_child, leave_pkg_prefix=False) - temp = strFunctions.remove_prefix(lo_child['element']) - lo_name = loname[7:] #strFunctions.plural(temp) - text = 'A {0} object may have the optional SBML Level~3 ' \ - 'Core attributes {1} and {2}. No other attributes from the ' \ - 'SBML Level~3 Core namespaces are permitted on a {0} object.'\ - .format(strFunctions.get_tex_element_name(lo_child, False), - strFunctions.wrap_token('metaid'), - strFunctions.wrap_token('sboTerm')) - sec_name = 'listof' + lo_name.lower() - ref = '{0}, {1}.'\ - .format(self.pkg_ref, strFunctions.wrap_section(sec_name)) - sev = 'ERROR' - lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) - tc = '{0}{1}LO{2}AllowedCoreAttributes'.format(self.up_package, - self.name, lo_name) - lo = True - short = 'Core attributes allowed on .'.format(lo_name) + if lo_child is None: + text = '{0} {1} object may have the optional SBML Level~3 ' \ + 'Core attributes {2} and {3}. No other attributes from the ' \ + 'SBML Level~3 Core namespaces are permitted on {4} {1}.'\ + .format(self.indef_u, self.formatted_name, + strFunctions.wrap_token('metaid'), + strFunctions.wrap_token('sboTerm'), self.indef) + ref = 'SBML Level~3 Version~1 Core, Section~3.2.' + sev = 'ERROR' + lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) + tc = '{0}{1}AllowedCoreAttributes'.format(self.up_package, + self.name) + short = 'Core attributes allowed on <{0}>.'.format(self.lower_name) + lo = False + else: + loname = strFunctions.get_tex_element_name(lo_child, leave_pkg_prefix=False) + temp = strFunctions.remove_prefix(lo_child['element']) + lo_name = loname[7:] #strFunctions.plural(temp) + text = 'A {0} object may have the optional attribute {1}. No other attributes from the ' \ + '{2} Level~{3} Version~{4} namespaces are permitted on a {0} object.'\ + .format(strFunctions.get_tex_element_name(lo_child, False), + strFunctions.wrap_token('metaid'), + global_variables.language.upper(), + global_variables.namespaces[0]['level'], + global_variables.namespaces[0]['version'] + ) + sec_name = 'listof' + lo_name.lower() + ref = '{0}, {1}.'\ + .format(self.pkg_ref, strFunctions.wrap_section(sec_name)) + sev = 'ERROR' + lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) + tc = '{0}{1}LO{2}AllowedCoreAttributes'.format(self.up_package, + self.name, lo_name) + lo = True + short = 'Core attributes allowed on .'.format(lo_name) + lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref, + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref, 'plugin': False, 'object': self.name, 'lo': lo, 'reqd': self.reqd_elem, 'opt': self.opt_elem}) # write core subobjects rule @staticmethod def write_core_subobject_rule(self, lo_child=None): - if lo_child is None: - text = '{0} {1} object may have the optional SBML Level~3 ' \ - 'Core subobjects for notes and annotations. No other ' \ - 'elements from the SBML Level~3 Core namespaces are ' \ - 'permitted on {2} {1}.'\ - .format(self.indef_u, self.formatted_name, self.indef) - ref = 'SBML Level~3 Version~1 Core, Section~3.2.' - sev = 'ERROR' - lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) - tc = '{0}{1}AllowedCoreElements'.format(self.up_package, self.name) - short = 'Core elements allowed on <{0}>.'.format(self.lower_name) - lo = False + if global_variables.is_sbml: + if lo_child is None: + text = '{0} {1} object may have the optional SBML Level~3 ' \ + 'Core subobjects for notes and annotations. No other ' \ + 'elements from the SBML Level~3 Core namespaces are ' \ + 'permitted on {2} {1}.'\ + .format(self.indef_u, self.formatted_name, self.indef) + ref = 'SBML Level~3 Version~1 Core, Section~3.2.' + sev = 'ERROR' + lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) + tc = '{0}{1}AllowedCoreElements'.format(self.up_package, self.name) + short = 'Core elements allowed on <{0}>.'.format(self.lower_name) + lo = False + else: + loname = strFunctions.get_tex_element_name(lo_child, leave_pkg_prefix=False) + temp = strFunctions.remove_prefix(lo_child['element']) + lo_name = loname[7:] #strFunctions.plural(temp) + text = r'Apart from the general notes and annotations subobjects ' \ + r'permitted on all SBML objects, a {0} container object ' \ + r'may only contain \{1} objects.'\ + .format(loname, temp) + sec_name = 'listof' + lo_name.lower() + ref = '{0}, {1}.'\ + .format(self.pkg_ref, strFunctions.wrap_section(sec_name)) + sev = 'ERROR' + lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) + tc = '{0}{1}LO{2}AllowedCoreElements'.format(self.up_package, self.name, + lo_name) + lo = True + short = 'Core elements allowed on .'.format(lo_name) + lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) else: - loname = strFunctions.get_tex_element_name(lo_child, leave_pkg_prefix=False) - temp = strFunctions.remove_prefix(lo_child['element']) - lo_name = loname[7:] #strFunctions.plural(temp) - text = r'Apart from the general notes and annotations subobjects ' \ - r'permitted on all SBML objects, a {0} container object ' \ - r'may only contain \{1} objects.'\ - .format(loname, temp) - sec_name = 'listof' + lo_name.lower() - ref = '{0}, {1}.'\ - .format(self.pkg_ref, strFunctions.wrap_section(sec_name)) - sev = 'ERROR' - lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) - tc = '{0}{1}LO{2}AllowedCoreElements'.format(self.up_package, self.name, - lo_name) - lo = True - short = 'Core elements allowed on .'.format(lo_name) - lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) + if lo_child is None: + text = '{0} {1} object may have the optional SBML Level~3 ' \ + 'Core subobjects for notes and annotations. No other ' \ + 'elements from the SBML Level~3 Core namespaces are ' \ + 'permitted on {2} {1}.'\ + .format(self.indef_u, self.formatted_name, self.indef) + ref = 'SBML Level~3 Version~1 Core, Section~3.2.' + sev = 'ERROR' + lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) + tc = '{0}{1}AllowedCoreElements'.format(self.up_package, self.name) + short = 'Core elements allowed on <{0}>.'.format(self.lower_name) + lo = False + else: + child = strFunctions.remove_prefix(lo_child['element']) + loname = strFunctions.list_of_name(child, False) + text = r'Apart from the general \notes and \{2} subobjects ' \ + r'permitted on all {3} objects, a \{0} container object ' \ + r'may only contain \{1} objects.' \ + .format(loname, child, global_variables.annot_element, + global_variables.language.upper()) + sec_name = loname.lower() + ref = '{0}, {1}.' \ + .format(self.pkg_ref, strFunctions.wrap_section(sec_name)) + sev = 'ERROR' + lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) + tc = '{0}{1}LO{2}AllowedCoreElements'.format(self.up_package, self.name, child) + lo = True + short = 'Core elements allowed on .'.format(child) + lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) + return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref, + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref, 'plugin': False, 'object': self.name, 'lo': lo, 'reqd': self.reqd_elem, 'opt': self.opt_elem}) @@ -427,9 +516,16 @@ def write_package_attribute_rule(self): return reqd = self.parse_required(self, self.reqd_att) opt = self.parse_optional(self, self.opt_att) - no_other_statement = 'No other attributes from the SBML Level~3 {0} ' \ - 'namespaces are permitted on {1} {2} object. '\ - .format(self.fullname, self.indef, self.formatted_name) + if global_variables.is_sbml: + no_other_statement = 'No other attributes from the SBML Level~3 {0} ' \ + 'namespaces are permitted on {1} {2} object. '\ + .format(self.fullname, self.indef, self.formatted_name) + else: + no_other_statement = 'No other attributes from the {3} Level~{4} Version~{5} ' \ + 'namespaces are permitted on {1} {2} object. ' \ + .format(self.fullname, self.indef, self.formatted_name, global_variables.language.upper(), + global_variables.namespaces[0]['level'], global_variables.namespaces[0]['version']) + if len(opt) == 0 and len(reqd) > 0: text = '{0} {1} object must have {2}. {3}'\ .format(self.indef_u, self.formatted_name, @@ -451,7 +547,7 @@ def write_package_attribute_rule(self): tc = '{0}{1}AllowedAttributes'.format(self.up_package, self.name) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref, + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref, 'plugin': False, 'object': self.name, 'lo': False, 'reqd': self.reqd_att, 'opt': self.opt_att}) @@ -461,21 +557,43 @@ def write_package_object_rule(self): return reqd = self.parse_required_elements(self.reqd_elem) opt = self.parse_optional_elements(self.opt_elem) - no_other_statement = 'No other elements from the SBML Level~3 {0} ' \ - 'namespaces are permitted on {1} {2} object. '\ - .format(self.fullname, self.indef, self.formatted_name) - if len(opt) == 0 and len(reqd) > 0: - text = '{0} {1} object must contain {2}. {3}'\ - .format(self.indef_u, self.formatted_name, - reqd, no_other_statement) - elif len(reqd) == 0 and len(opt) > 0: - text = '{0} {1} object may contain {2}. {3}'\ - .format(self.indef_u, self.formatted_name, - opt, no_other_statement) + if global_variables.is_sbml: + no_other_statement = 'No other elements from the SBML Level~3 {0} ' \ + 'namespaces are permitted on {1} {2} object. '\ + .format(self.fullname, self.indef, self.formatted_name) + if len(opt) == 0 and len(reqd) > 0: + text = '{0} {1} object must contain {2}. {3}'\ + .format(self.indef_u, self.formatted_name, + reqd, no_other_statement) + elif len(reqd) == 0 and len(opt) > 0: + text = '{0} {1} object may contain {2}. {3}'\ + .format(self.indef_u, self.formatted_name, + opt, no_other_statement) + else: + text = '{0} {1} object must contain {2}, and may contain {3}. {4}'\ + .format(self.indef_u, self.formatted_name, + reqd, opt, no_other_statement) else: - text = '{0} {1} object must contain {2}, and may contain {3}. {4}'\ - .format(self.indef_u, self.formatted_name, - reqd, opt, no_other_statement) + common = 'Apart from the general \\{0} and \\{1} subobjects permitted ' \ + 'on all {2} components,'.format('Notes', global_variables.annot_element, + global_variables.language.upper()) + no_other_statement = 'No other objects from the {3} Level~{4} Version~{5} ' \ + 'namespaces are permitted on {1} {2} object. ' \ + .format(self.fullname, self.indef, self.formatted_name, global_variables.language.upper(), + global_variables.namespaces[0]['level'], global_variables.namespaces[0]['version']) + if len(opt) == 0 and len(reqd) > 0: + text = '{4} {0} {1} object must contain {2}. {3}'\ + .format(self.indef_u, self.formatted_name, + reqd, no_other_statement, common) + elif len(reqd) == 0 and len(opt) > 0: + text = '{4} {0} {1} object may contain {2}. {3}'\ + .format(self.indef_u, self.formatted_name, + opt, no_other_statement, common) + else: + text = '{5} {0} {1} object must contain {2}, and may contain {3}. {4}'\ + .format(self.indef_u, self.formatted_name, + reqd, opt, no_other_statement, common) + ref = '{0}, {1}.'\ .format(self.pkg_ref, strFunctions.wrap_section(self.name)) sev = 'ERROR' @@ -485,7 +603,7 @@ def write_package_object_rule(self): tc = '{0}{1}AllowedElements'.format(self.up_package, self.name) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref, + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref, 'plugin': False, 'object': self.name, 'reqd': self.reqd_elem, 'opt': self.opt_elem}) @@ -548,7 +666,7 @@ def write_lochild_attribute_rule(self, child, lo_info): strFunctions.plural(name)) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref, + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref, 'plugin': False, 'object': self.name, 'lo': True, 'reqd': child_reqd, 'opt': child_opt, 'lo_object': lo_info[0]['name']}) @@ -613,7 +731,7 @@ def write_optional_lo_rule(self): tc = '{0}{1}EmptyLOElements'.format(self.up_package, self.name, ) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref, + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref, 'plugin': False, 'object': self.name, 'lo_object': self.opt_child_lo_elem}) @@ -674,7 +792,7 @@ def write_reqd_lo_rule(self): tc = '{0}{1}EmptyReqdLOElements'.format(self.up_package, self.name) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) ######################################################################### @@ -682,6 +800,10 @@ def write_reqd_lo_rule(self): # parse the required attribute sentence @staticmethod def parse_required(self, attributes): + if global_variables.is_sbml: + prefix = self.package + else: + prefix = global_variables.language for attrib in attributes: if 'texname' not in attrib or attrib['texname'] == 'RelAbsVector': attrib['texname'] = attrib['name'] @@ -691,25 +813,31 @@ def parse_required(self, attributes): elif num == 1: return 'the required attribute {0}'\ .format(strFunctions.wrap_token(attributes[0]['texname'], - self.package)) + prefix)) else: required_statement = 'the required attributes {0}'\ .format(strFunctions.wrap_token(attributes[0]['texname'], - self.package)) + prefix)) i = 1 while i < num - 1: required_statement += ', {0}'\ .format(strFunctions.wrap_token(attributes[i]['texname'], - self.package)) + prefix)) i += 1 required_statement += ' and {0}'\ .format(strFunctions.wrap_token(attributes[i]['texname'], - self.package)) + prefix)) return required_statement # parse the optional attribute sentence @staticmethod def parse_optional(self, attributes): + if global_variables.is_sbml: + prefix = self.package + else: + prefix = global_variables.language + metaid = {'name': 'metaid', 'type': 'string'} + attributes.append(metaid) for attrib in attributes: if 'texname' not in attrib or attrib['texname'] == 'RelAbsVector': attrib['texname'] = attrib['name'] @@ -719,20 +847,20 @@ def parse_optional(self, attributes): elif num == 1: return 'the optional attribute {0}' \ .format(strFunctions.wrap_token(attributes[0]['texname'], - self.package)) + prefix)) else: optional_statement = 'the optional attributes {0}' \ .format(strFunctions.wrap_token(attributes[0]['texname'], - self.package)) + prefix)) i = 1 while i < num - 1: optional_statement += ', {0}' \ .format(strFunctions.wrap_token(attributes[i]['texname'], - self.package)) + prefix)) i += 1 optional_statement += ' and {0}' \ .format(strFunctions.wrap_token(attributes[i]['texname'], - self.package)) + prefix)) return optional_statement # parse the required elements sentence diff --git a/deviser/validation/ValidationRulesGeneral.py b/deviser/validation/ValidationRulesGeneral.py index 0fb4f9eac..519046688 100644 --- a/deviser/validation/ValidationRulesGeneral.py +++ b/deviser/validation/ValidationRulesGeneral.py @@ -40,11 +40,11 @@ from ..util import strFunctions, global_variables -class ValidationRulesGeneral(): +class ValidationRulesGeneral: """Class for creating the general validation rules""" def __init__(self, spec_name, number, package, pkg_ref, level, version, - pkg_version, reqd_status): + pkg_version, reqd_status, full_pkg_command): # members from object self.fullname = spec_name self.number = number @@ -57,8 +57,7 @@ def __init__(self, spec_name, number, package, pkg_ref, level, version, else: self.reqd_status = 'false' - self.full_pkg_command = \ - '\\{0}Package'.format(strFunctions.texify(self.fullname)) + self.full_pkg_command = full_pkg_command # useful repeated text strings self.valid = '\\validRule{' self.start_b = '{' @@ -70,6 +69,13 @@ def __init__(self, spec_name, number, package, pkg_ref, level, version, self.rules = [] self.tc = 'TBC' + # constants for rules + if global_variables.is_sbml: + self.lib_ref = 'L3V1 {0} V1 Section 3.1'.format(self.up_package) + self.up_package = strFunctions.upper_first(self.package) + else: + self.lib_ref = '{0} L{1}V{2} Section '.format(self.up_package.upper(), self.level, self.version) + self.up_package = self.package.upper() ######################################################################## @@ -77,53 +83,98 @@ def __init__(self, spec_name, number, package, pkg_ref, level, version, def determine_rules(self): # write rules increasing the number - self.number += 10100 - rule = self.write_unknown_rule(self) - self.add_rule(rule) + if global_variables.is_sbml: + self.number += 10100 + rule = self.write_unknown_rule(self) + self.add_rule(rule) - self.number += 1 - rule = self.write_ns_rule(self) - self.add_rule(rule) + self.number += 1 + rule = self.write_ns_rule(self) + self.add_rule(rule) - self.number += 1 - rule = self.write_element_not_ns_rule(self) - self.add_rule(rule) + self.number += 1 + rule = self.write_element_not_ns_rule(self) + self.add_rule(rule) - self.number = self.offset + 10301 - rule = self.write_id_rule(self) - self.add_rule(rule) + self.number = self.offset + 10301 + rule = self.write_id_rule(self) + self.add_rule(rule) - self.number += 1 - rule = self.write_id_syntax_rule(self) - self.add_rule(rule) + self.number += 1 + rule = self.write_id_syntax_rule(self) + self.add_rule(rule) - if global_variables.is_package: - self.number = self.offset + 20101 - rule = self.write_reqd_rule(self) + if global_variables.is_package: + self.number = self.offset + 20101 + rule = self.write_reqd_rule(self) + self.add_rule(rule) + + self.number += 1 + rule = self.write_reqd_bool_rule(self) + self.add_rule(rule) + + self.number += 1 + rule = self.write_reqd_value_rule(self) + self.add_rule(rule) + else: + self.number += 1 + rule = self.write_metaid_syntax_rule(self) + self.add_rule(rule) + + self.number = self.offset + 20101 + rule = self.write_valid_ns_rule(self) + self.add_rule(rule) + + self.number += 1 + rule = self.write_allowed_attributes_rule(self) + self.add_rule(rule) + + self.number += 1 + rule = self.write_empty_list_rule(self) + self.add_rule(rule) + else: + self.number += 10100 + rule = self.write_unknown_rule(self) self.add_rule(rule) self.number += 1 - rule = self.write_reqd_bool_rule(self) + rule = self.write_ns_rule(self) self.add_rule(rule) self.number += 1 - rule = self.write_reqd_value_rule(self) + rule = self.write_element_not_ns_rule(self) self.add_rule(rule) - else: - self.number += 1 + + self.number = 10201 rule = self.write_metaid_syntax_rule(self) self.add_rule(rule) - self.number = self.offset + 20101 - rule = self.write_valid_ns_rule(self) + self.number = 10301 + rule = self.write_annotation_rule(self, 1) + self.add_rule(rule) + + self.number += 1 + rule = self.write_annotation_rule(self, 2) + self.add_rule(rule) + + self.number += 1 + rule = self.write_annotation_rule(self, 3) + self.add_rule(rule) + + self.number = 10401 + rule = self.write_notes_rule(self, 1) + self.add_rule(rule) + + self.number += 1 + rule = self.write_notes_rule(self, 2) self.add_rule(rule) self.number += 1 - rule = self.write_allowed_attributes_rule(self) + rule = self.write_notes_rule(self, 3) self.add_rule(rule) self.number += 1 - rule = self.write_empty_list_rule(self) + rule = self.write_notes_rule(self, 4) self.add_rule(rule) def add_rule(self, rule): @@ -140,27 +191,37 @@ def add_rule(self, rule): # write rule about ns @staticmethod def write_unknown_rule(self): - text = 'Unknown error from {0}'.format(self.up_package) + text = 'Unknown error from {0}'.format(self.up_package.upper()) ref = '' sev = 'ERROR' lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) - short = 'Unknown error from {0}'.format(self.up_package) - lib_ref = '' + short = 'Unknown error from {0}'.format(self.up_package.upper())*10 tc = global_variables.unknown_error return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) # write rules about ns @staticmethod def write_ns_rule(self): - text = 'To conform to the {0} specification for SBML Level~{1} ' \ - 'Version~{2}, an SBML document must declare ' \ - '\\uri{3}http://www.sbml.org/sbml/' \ - 'level{1}/version{2}/{4}/version{5}{6} as the XMLNamespace ' \ - 'to use for elements of this package.'\ - .format(self.full_pkg_command, self.level, self.version, - self.start_b, self.package, self.pkg_version, self.end_b) + if global_variables.is_sbml: + text = 'To conform to the {0} specification for {7} Level~{1} ' \ + 'Version~{2}, an {7} document must declare ' \ + '\\uri{3}http://www.sbml.org/sbml/' \ + 'level{1}/version{2}/{4}/version{5}{6} as the XMLNamespace ' \ + 'to use for elements of this package.'\ + .format(self.full_pkg_command, self.level, self.version, + self.start_b, self.package, self.pkg_version, self.end_b, + global_variables.language.upper()) + else: + text = 'To conform to the {0} specification for {7} Level~{1} ' \ + 'Version~{2}, an {7} document must declare ' \ + '\\uri{3}{8}{6} as the XMLNamespace ' \ + 'to use for elements of this package.'\ + .format(self.full_pkg_command, self.level, self.version, + self.start_b, self.package, self.pkg_version, self.end_b, + global_variables.language.upper(), global_variables.namespaces[0]['namespace']) + ref = '{0} {1}.'\ .format(self.pkg_ref, strFunctions.wrap_section('xml-namespace', False)) @@ -168,32 +229,40 @@ def write_ns_rule(self): lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) short = 'The {0} namespace is not correctly ' \ 'declared.'.format(self.up_package) - lib_ref = 'L3V1 {0} V1 Section 3.1'.format(self.up_package) + tc = '{0}NSUndeclared'.format(self.up_package) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) @staticmethod def write_element_not_ns_rule(self): - text = 'Wherever they appear in an SBML document, elements and ' \ - 'attributes from the {0} must use the ' \ - '\\uri{1}http://www.sbml.org/sbml/level{2}/version{3}' \ - '/{4}/version{5}{6} namespace, declaring so either explicitly ' \ - 'or implicitly.'\ - .format(self.full_pkg_command, self.start_b, self.level, - self.version, self.package, self.pkg_version, self.end_b) + if global_variables.is_sbml: + text = 'Wherever they appear in an SBML document, elements and ' \ + 'attributes from the {0} must use the ' \ + '\\uri{1}http://www.sbml.org/sbml/level{2}/version{3}' \ + '/{4}/version{5}{6} namespace, declaring so either explicitly ' \ + 'or implicitly.'\ + .format(self.full_pkg_command, self.start_b, self.level, + self.version, self.package, self.pkg_version, self.end_b) + else: + text = 'Wherever they appear in a {7} document, elements and ' \ + 'attributes from the {0} must use the ' \ + '\\uri{1}{8}{6} namespace, declaring so either explicitly ' \ + 'or implicitly.' \ + .format(self.full_pkg_command, self.start_b, self.level, + self.version, self.package, self.pkg_version, self.end_b, + global_variables.language.upper(), global_variables.namespaces[0]['namespace']) ref = '{0} {1}.'\ .format(self.pkg_ref, strFunctions.wrap_section('xml-namespace', False)) sev = 'ERROR' lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) short = 'Element not in {0} namespace'.format(self.up_package) - lib_ref = 'L3V1 {0} V1 Section 3.1'.format(self.up_package) tc = '{0}ElementNotInNs'.format(self.up_package) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) @staticmethod def write_id_rule(self): @@ -206,11 +275,10 @@ def write_id_rule(self): sev = 'ERROR' lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) short = 'Duplicate \'id\' attribute value' - lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) tc = '{0}DuplicateComponentId'.format(self.up_package) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) @staticmethod def write_id_syntax_rule(self): @@ -225,11 +293,10 @@ def write_id_syntax_rule(self): sev = 'ERROR' lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) short = 'Invalid SId syntax'.format(self.up_package) - lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) tc = '{0}IdSyntaxRule'.format(self.up_package) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) @staticmethod def write_reqd_rule(self): @@ -242,11 +309,10 @@ def write_reqd_rule(self): sev = 'ERROR' lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) short = 'Required {0}:required attribute on '.format(self.package) - lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) tc = '{0}AttributeRequiredMissing'.format(self.up_package) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) @staticmethod def write_reqd_bool_rule(self): @@ -259,11 +325,10 @@ def write_reqd_bool_rule(self): lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) short = 'The {0}:required attribute must be Boolean' \ ''.format(self.package) - lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) tc = '{0}AttributeRequiredMustBeBoolean'.format(self.up_package) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) @staticmethod def write_reqd_value_rule(self): @@ -278,29 +343,34 @@ def write_reqd_value_rule(self): lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) short = 'The {0}:required attribute must be \'{1}\'' \ ''.format(self.package, self.reqd_status) - lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) tc = '{0}AttributeRequiredMustHaveValue'.format(self.up_package) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) @staticmethod def write_metaid_syntax_rule(self): - text = 'The value of a {0} must conform to the syntax of ' \ - 'the XML Type ID'\ - .format(strFunctions.wrap_token('metaid', self.package)) - ref = 'SBML Level~3 Version~1 Core, Section~3.1.6.' + if global_variables.is_sbml: + text = 'The value of a {0} must conform to the syntax of ' \ + 'the XML Type ID'\ + .format(strFunctions.wrap_token('metaid', self.package)) + ref = 'SBML Level~3 Version~1 Core, Section~3.1.6.' + else: + text = 'The value of a {0} must conform to the syntax of ' \ + 'the XML Type ID'\ + .format(strFunctions.wrap_token('metaid', self.package)) + ref = 'metaid' + # ref = '{0} {1}.'\ # .format(self.pkg_ref, # strFunctions.wrap_section('primitive-types', False)) sev = 'ERROR' lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) short = 'Invalid SId syntax'.format(self.up_package) - lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) tc = '{0}InvalidMetaidSyntax'.format(global_variables.prefix) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) @staticmethod def write_valid_ns_rule(self): @@ -311,11 +381,10 @@ def write_valid_ns_rule(self): sev = 'ERROR' lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) short = 'Invalid namespace'.format(self.up_package) - lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) tc = 'InvalidNamespaceOn{0}'.format(global_variables.prefix) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) @staticmethod def write_allowed_attributes_rule(self): @@ -326,11 +395,10 @@ def write_allowed_attributes_rule(self): sev = 'ERROR' lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) short = 'Allowed attributes'.format(self.up_package) - lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) tc = 'AllowedAttributes'.format(self.up_package) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) @staticmethod def write_empty_list_rule(self): @@ -341,9 +409,66 @@ def write_empty_list_rule(self): sev = 'ERROR' lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) short = 'No empty listOf'.format(self.up_package) - lib_ref = 'L3V1 {0} V1 Section'.format(self.up_package) tc = '{0}EmptyListElement'.format(global_variables.prefix) return dict({'number': self.number, 'text': text, 'reference': ref, 'severity': sev, 'typecode': tc, - 'lib_sev': lib_sev, 'short': short, 'lib_ref': lib_ref}) + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) + + @staticmethod + def write_annotation_rule(self, num): + if num == 1: + text = 'Every top-level XML element within an \\{0} object must ' \ + 'have an XML namespace declared.'.format(global_variables.annot_element) + short = 'No ns for {0}'.format(global_variables.annot_element) + tc = '{0}NoAnnotationNS'.format(global_variables.prefix) + elif num == 2: + text = 'A given XML namespace cannot be the namespace of more than one top-level' \ + 'element within a given \\{0} object.'.format(global_variables.annot_element) + short = 'Repeat ns for {0}'.format(global_variables.annot_element) + tc = '{0}RepeatAnnotationNS'.format(global_variables.prefix) + else: + text = 'A given {0} element may contain at most one \\{1} ' \ + 'subobject.'.format(global_variables.language.upper(), global_variables.annot_element) + short = 'Only one {0}'.format(global_variables.annot_element) + tc = '{0}OnlyOneAnnotation'.format(global_variables.prefix) + ref = '{0} {1}.' \ + .format(self.pkg_ref, + strFunctions.wrap_section('annotation-use', False)) + sev = 'ERROR' + lib_sev = '{0}_SEV_ERROR'.format(global_variables.up_full_lib) + return dict({'number': self.number, 'text': text, + 'reference': ref, 'severity': sev, 'typecode': tc, + 'lib_sev': lib_sev, 'short': short, 'lib_ref': self.lib_ref}) + + @staticmethod + def write_notes_rule(self, num): + if num == 1: + text = 'The contents of a \\{0} object must be explicitly placed in the ' \ + 'XHTML XML namespace. '.format('Notes') + short = 'Notes not in XHTML' + tc = 'NotesInXHTML' + elif num == 2: + text = 'The contents of a \\{0} object must not contain an XML declaration, ' \ + '\\ie a string of the form \\val{1}{2} or ' \ + 'similar.'.format('Notes', '{', '}') + short = 'No XML decl in Notes' + tc = 'XMLDeclNotes' + elif num == 3: + text = 'The content of a \\{0} object must not contain an XML DOCTYPE declaration, ' \ + '\\ie a string beginning with the characters \\val{1}