diff --git a/VERSION.txt b/VERSION.txt index ff34506dab..64dfc5d6a9 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.19.5 +5.19.6 diff --git a/configure b/configure index 953ceb5279..66ecce835e 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh # From configure.ac Revision. # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libSBML 5.19.5. +# Generated by GNU Autoconf 2.69 for libSBML 5.19.6. # # Report bugs to . # @@ -735,8 +735,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libSBML' PACKAGE_TARNAME='libsbml' -PACKAGE_VERSION='5.19.5' -PACKAGE_STRING='libSBML 5.19.5' +PACKAGE_VERSION='5.19.6' +PACKAGE_STRING='libSBML 5.19.6' PACKAGE_BUGREPORT='libsbml-team@googlegroups.com' PACKAGE_URL='http://sbml.org/Software/libSBML' @@ -1629,7 +1629,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libSBML 5.19.5 to adapt to many kinds of systems. +\`configure' configures libSBML 5.19.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1695,7 +1695,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libSBML 5.19.5:";; + short | recursive ) echo "Configuration of libSBML 5.19.6:";; esac cat <<\_ACEOF @@ -1851,7 +1851,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libSBML configure 5.19.5 +libSBML configure 5.19.6 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2570,7 +2570,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libSBML $as_me 5.19.5, which was +It was created by libSBML $as_me 5.19.6, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -27754,7 +27754,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libSBML $as_me 5.19.5, which was +This file was extended by libSBML $as_me 5.19.6, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -27817,7 +27817,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libSBML config.status 5.19.5 +libSBML config.status 5.19.6 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/src/sbml/common/libsbml-version.h b/src/sbml/common/libsbml-version.h index 02335a06a4..f206647df9 100644 --- a/src/sbml/common/libsbml-version.h +++ b/src/sbml/common/libsbml-version.h @@ -51,7 +51,7 @@ * * A version string of the form "1.2.3". */ -#define LIBSBML_DOTTED_VERSION "5.19.5" +#define LIBSBML_DOTTED_VERSION "5.19.6" /** diff --git a/src/sbml/packages/fbc/extension/FbcSBasePlugin.cpp b/src/sbml/packages/fbc/extension/FbcSBasePlugin.cpp index a5eab8faa4..d94d528786 100644 --- a/src/sbml/packages/fbc/extension/FbcSBasePlugin.cpp +++ b/src/sbml/packages/fbc/extension/FbcSBasePlugin.cpp @@ -230,7 +230,7 @@ FbcSBasePlugin::createKeyValuePair() try { - FBC_CREATE_NS(fbcns, getSBMLNamespaces()); + FBC_CREATE_NS_WITH_VERSION(fbcns, getSBMLNamespaces(), getPackageVersion()); kvp = new KeyValuePair(fbcns); delete fbcns; } @@ -872,87 +872,94 @@ FbcSBasePlugin::createObject(XMLInputStream& stream) /** @endcond */ -/** @cond doxygenLibsbmlInternal */ -/** -* Synchronizes the annotation of this SBML object. -* -* Annotation element (XMLNode* mAnnotation) is synchronized with the -* current CVTerm objects (List* mCVTerm). -* Currently, this method is called in getAnnotation, isSetAnnotation, -* and writeElements methods. -*/ -void -FbcSBasePlugin::writeKeyValuePairsAnnotation(SBase* parentObject) const -{ - if (parentObject == NULL) return; - - - XMLNode *parentAnnotation = parentObject->getAnnotation(); - if (parentAnnotation != NULL && parentAnnotation->getNumChildren() > 0) - { -// deleteFbcAnnotation(parentAnnotation); - } - - XMLToken ann_token = XMLToken(XMLTriple("annotation", "", ""), XMLAttributes()); - XMLNode* annt = new XMLNode(ann_token); - - - - if (mKeyValuePairs.size() > 0) - { - XMLAttributes loga_attr = XMLAttributes(); - loga_attr.add("xmlns", FbcExtension::getXmlnsL3V1V3()); - XMLToken loga_token = XMLToken(XMLTriple("listOfKeyValuePairs", FbcExtension::getXmlnsL3V1V1(), ""), loga_attr); - XMLNode loga = XMLNode(loga_token); - - for (unsigned int i = 0; i < mKeyValuePairs.size(); ++i) - loga.addChild(mKeyValuePairs.get(i)->toXML()); - - // then add the ones toXML() - annt->addChild(loga); - } - - - if (annt && annt->getNumChildren() > 0) - { - parentObject->appendAnnotation(annt); - } - delete annt; -} -/** @endcond */ - - -/** @cond doxygenLibsbmlInternal */ -/** -* Parse L2 annotation if supported -* -*/ -void -FbcSBasePlugin::parseAnnotation(SBase *parentObject, XMLNode *pAnnotation) -{ - mKeyValuePairs.setSBMLDocument(mSBML); - // don't read if we have an invalid node or already a gene associations object - if (pAnnotation == NULL || mKeyValuePairs.size() > 0) - return; - - // annotation element has been parsed by the parent element - // (Model) of this plugin object, thus the annotation element - // set to the above pAnnotation variable is parsed in this block. - - XMLNode& listOfKeyValuePairs = pAnnotation->getChild("listOfKeyValuePairs"); - if (listOfKeyValuePairs.getNumChildren() == 0) - return; - - // read the xml node, overriding that all errors are flagged as - // warnings - mKeyValuePairs.read(listOfKeyValuePairs, LIBSBML_OVERRIDE_WARNING); - // remove listOfLayouts annotation - parentObject->removeTopLevelAnnotationElement("listOfKeyValuePairs", "", false); - -} -/** @endcond */ - - +/** @cond doxygenLibsbmlInternal */ +/** +* Synchronizes the annotation of this SBML object. +* +* Annotation element (XMLNode* mAnnotation) is synchronized with the +* current CVTerm objects (List* mCVTerm). +* Currently, this method is called in getAnnotation, isSetAnnotation, +* and writeElements methods. +*/ +void +FbcSBasePlugin::writeKeyValuePairsAnnotation(SBase* parentObject) const +{ + if (parentObject == NULL) return; + + + XMLNode *parentAnnotation = parentObject->getAnnotation(); + if (parentAnnotation != NULL && parentAnnotation->getNumChildren() > 0) + { +// deleteFbcAnnotation(parentAnnotation); + } + + XMLToken ann_token = XMLToken(XMLTriple("annotation", "", ""), XMLAttributes()); + XMLNode* annt = new XMLNode(ann_token); + + + + if (mKeyValuePairs.size() > 0) + { + XMLAttributes loga_attr = XMLAttributes(); + loga_attr.add("xmlns", mKeyValuePairs.getXmlns()); + XMLToken loga_token = XMLToken(XMLTriple("listOfKeyValuePairs", mKeyValuePairs.getXmlns(), ""), loga_attr); + XMLNode loga = XMLNode(loga_token); + + for (unsigned int i = 0; i < mKeyValuePairs.size(); ++i) + loga.addChild(mKeyValuePairs.get(i)->toXML()); + + // then add the ones toXML() + annt->addChild(loga); + } + + + if (annt && annt->getNumChildren() > 0) + { + parentObject->appendAnnotation(annt); + } + delete annt; +} +/** @endcond */ + + +/** @cond doxygenLibsbmlInternal */ +/** +* Parse L2 annotation if supported +* +*/ +void +FbcSBasePlugin::parseAnnotation(SBase *parentObject, XMLNode *pAnnotation) +{ + mKeyValuePairs.setSBMLDocument(mSBML); + // don't read if we have an invalid node or already a gene associations object + if (pAnnotation == NULL || mKeyValuePairs.size() > 0) + return; + + // annotation element has been parsed by the parent element + // (Model) of this plugin object, thus the annotation element + // set to the above pAnnotation variable is parsed in this block. + + XMLNode& listOfKeyValuePairs = pAnnotation->getChild("listOfKeyValuePairs"); + if (listOfKeyValuePairs.getNumChildren() == 0) + return; + + XMLNamespaces oldNs = listOfKeyValuePairs.getNamespaces(); + + // read the xml node, overriding that all errors are flagged as + // warnings + mKeyValuePairs.read(listOfKeyValuePairs, LIBSBML_OVERRIDE_WARNING); + + // unfortunately the namespaces are overwritten at that point with the one from the + // document, so restore it + mKeyValuePairs.setXmlns(&oldNs, listOfKeyValuePairs.getPrefix()); + + // remove listOfLayouts annotation + parentObject->removeTopLevelAnnotationElement("listOfKeyValuePairs", "", false); + +} +/** @endcond */ + + diff --git a/src/sbml/packages/fbc/extension/test/TestWriteFbcExtension.cpp b/src/sbml/packages/fbc/extension/test/TestWriteFbcExtension.cpp index d4706acb29..24767a865e 100644 --- a/src/sbml/packages/fbc/extension/test/TestWriteFbcExtension.cpp +++ b/src/sbml/packages/fbc/extension/test/TestWriteFbcExtension.cpp @@ -451,10 +451,14 @@ START_TEST(test_FbcExtension_create_and_write_L3V1V3) FbcSBasePlugin* sbaseplugin3 = dynamic_cast(objective->getPlugin("fbc")); + ListOfKeyValuePairs *kvp_list = sbaseplugin3->getListOfKeyValuePairs(); + fail_unless(kvp_list->isSetXmlns()); + fail_unless(kvp_list->getXmlns() == "http://sbml.org/fbc/keyvaluepair"); + KeyValuePair * kvp3 = sbaseplugin3->createKeyValuePair(); - kvp3->setKey("key3"); - kvp3->setUri("my_annotation"); - kvp3->setValue("objective-value"); + fail_unless(kvp3->setKey("key3") == LIBSBML_OPERATION_SUCCESS); + fail_unless(kvp3->setUri("my_annotation") == LIBSBML_OPERATION_SUCCESS); + fail_unless(kvp3->setValue("objective-value") == LIBSBML_OPERATION_SUCCESS); //FbcSBasePlugin* sbaseplugin4 = dynamic_cast(document->getPlugin("fbc")); //// this dynamic cast is null diff --git a/src/sbml/packages/fbc/extension/test/test-data/fbc_example2_v3.xml b/src/sbml/packages/fbc/extension/test/test-data/fbc_example2_v3.xml index 869baa38e3..583b6a52e7 100644 --- a/src/sbml/packages/fbc/extension/test/test-data/fbc_example2_v3.xml +++ b/src/sbml/packages/fbc/extension/test/test-data/fbc_example2_v3.xml @@ -1,21 +1,15 @@ - - + - + @@ -24,7 +18,7 @@ - + @@ -33,7 +27,7 @@ - + @@ -44,13 +38,10 @@ - - - diff --git a/src/sbml/packages/fbc/sbml/KeyValuePair.cpp b/src/sbml/packages/fbc/sbml/KeyValuePair.cpp index f7972017e2..e52beddb24 100644 --- a/src/sbml/packages/fbc/sbml/KeyValuePair.cpp +++ b/src/sbml/packages/fbc/sbml/KeyValuePair.cpp @@ -236,10 +236,9 @@ int KeyValuePair::setId(const std::string& id) { unsigned int coreLevel = getLevel(); - unsigned int coreVersion = getVersion(); unsigned int pkgVersion = getPackageVersion(); - if (coreLevel == 3 && coreVersion == 1 && pkgVersion == 3) + if (coreLevel == 3 && pkgVersion == 3) { return SyntaxChecker::checkAndSetSId(id, mId); } @@ -257,10 +256,9 @@ int KeyValuePair::setName(const std::string& name) { unsigned int coreLevel = getLevel(); - unsigned int coreVersion = getVersion(); unsigned int pkgVersion = getPackageVersion(); - if (coreLevel == 3 && coreVersion == 1 && pkgVersion == 3) + if (coreLevel == 3 && pkgVersion == 3) { mName = name; return LIBSBML_OPERATION_SUCCESS; @@ -279,10 +277,9 @@ int KeyValuePair::setKey(const std::string& key) { unsigned int coreLevel = getLevel(); - unsigned int coreVersion = getVersion(); unsigned int pkgVersion = getPackageVersion(); - if (coreLevel == 3 && coreVersion == 1 && pkgVersion == 3) + if (coreLevel == 3 && pkgVersion == 3) { mKey = key; return LIBSBML_OPERATION_SUCCESS; @@ -301,10 +298,9 @@ int KeyValuePair::setValue(const std::string& value) { unsigned int coreLevel = getLevel(); - unsigned int coreVersion = getVersion(); unsigned int pkgVersion = getPackageVersion(); - if (coreLevel == 3 && coreVersion == 1 && pkgVersion == 3) + if (coreLevel == 3 && pkgVersion == 3) { mValue = value; return LIBSBML_OPERATION_SUCCESS; @@ -323,10 +319,9 @@ int KeyValuePair::setUri(const std::string& uri) { unsigned int coreLevel = getLevel(); - unsigned int coreVersion = getVersion(); unsigned int pkgVersion = getPackageVersion(); - if (coreLevel == 3 && coreVersion == 1 && pkgVersion == 3) + if (coreLevel == 3 && pkgVersion == 3) { mUri = uri; return LIBSBML_OPERATION_SUCCESS; @@ -860,10 +855,9 @@ KeyValuePair::addExpectedAttributes(ExpectedAttributes& attributes) SBase::addExpectedAttributes(attributes); unsigned int level = getLevel(); - unsigned int coreVersion = getVersion(); unsigned int pkgVersion = getPackageVersion(); - if (level == 3 && coreVersion == 1 && pkgVersion == 3) + if (level == 3 && pkgVersion == 3) { attributes.add("id"); attributes.add("name"); @@ -1122,16 +1116,16 @@ KeyValuePair::writeL3V1V3Attributes(XMLOutputStream& stream) const /** @endcond */ -/* -* Creates an XMLNode object from this. -*/ -XMLNode -KeyValuePair::toXML() const -{ - XMLNamespaces xmlns = XMLNamespaces(); - XMLTriple triple = XMLTriple(getElementName(), "", ""); - XMLAttributes att = XMLAttributes(); - +/* +* Creates an XMLNode object from this. +*/ +XMLNode +KeyValuePair::toXML() const +{ + XMLNamespaces xmlns = XMLNamespaces(); + XMLTriple triple = XMLTriple(getElementName(), "", ""); + XMLAttributes att = XMLAttributes(); + if (isSetId() == true) { att.add("id", mId); @@ -1156,14 +1150,14 @@ KeyValuePair::toXML() const { att.add("uri", mUri); } - - XMLToken token = XMLToken(triple, att, xmlns); - XMLNode node(token); - - return node; -} - - + + XMLToken token = XMLToken(triple, att, xmlns); + XMLNode node(token); + + return node; +} + + #endif /* __cplusplus */ diff --git a/src/sbml/packages/fbc/sbml/ListOfKeyValuePairs.cpp b/src/sbml/packages/fbc/sbml/ListOfKeyValuePairs.cpp index 0255c9080f..834dd1ad58 100644 --- a/src/sbml/packages/fbc/sbml/ListOfKeyValuePairs.cpp +++ b/src/sbml/packages/fbc/sbml/ListOfKeyValuePairs.cpp @@ -58,7 +58,7 @@ ListOfKeyValuePairs::ListOfKeyValuePairs(unsigned int level, unsigned int version, unsigned int pkgVersion) : ListOf(level, version) - , mXmlns ("") + , mXmlns ("http://sbml.org/fbc/keyvaluepair") { setSBMLNamespacesAndOwn(new FbcPkgNamespaces(level, version, pkgVersion)); } @@ -69,7 +69,7 @@ ListOfKeyValuePairs::ListOfKeyValuePairs(unsigned int level, */ ListOfKeyValuePairs::ListOfKeyValuePairs(FbcPkgNamespaces *fbcns) : ListOf(fbcns) - , mXmlns ("") + , mXmlns ("http://sbml.org/fbc/keyvaluepair") { setElementNamespace(fbcns->getURI()); } @@ -139,6 +139,16 @@ ListOfKeyValuePairs::isSetXmlns() const return (mXmlns.empty() == false); } +int +ListOfKeyValuePairs::setXmlns(const XMLNamespaces* xmlns, const std::string& prefix) +{ + if (xmlns == NULL) + mXmlns = ""; + else + mXmlns = xmlns->getURI(prefix); + + return LIBSBML_OPERATION_SUCCESS; +} /* * Sets the value of the "xmlns" attribute of this ListOfKeyValuePairs. @@ -150,7 +160,7 @@ ListOfKeyValuePairs::setXmlns(const std::string& xmlns) unsigned int coreVersion = getVersion(); unsigned int pkgVersion = getPackageVersion(); - if (coreLevel == 3 && coreVersion == 1 && pkgVersion == 3) + if (coreLevel == 3 && pkgVersion == 3) { mXmlns = xmlns; return LIBSBML_OPERATION_SUCCESS; @@ -376,7 +386,7 @@ ListOfKeyValuePairs::hasRequiredAttributes() const unsigned int version = getVersion(); unsigned int pkgVersion = getPackageVersion(); - if (level == 3 && version == 1 && pkgVersion == 3) + if (level == 3 && pkgVersion == 3) { if (isSetXmlns() == false) { @@ -399,7 +409,7 @@ ListOfKeyValuePairs::createObject(XMLInputStream& stream) { const std::string& name = stream.peek().getName(); SBase* object = NULL; - FBC_CREATE_NS_WITH_VERSION(fbcns, getSBMLNamespaces(), getPackageVersion()); + FBC_CREATE_NS_WITH_VERSION(fbcns, getSBMLNamespaces(), getPackageVersion()); if (name == "keyValuePair") { @@ -424,15 +434,6 @@ void ListOfKeyValuePairs::addExpectedAttributes(ExpectedAttributes& attributes) { ListOf::addExpectedAttributes(attributes); - - unsigned int level = getLevel(); - unsigned int coreVersion = getVersion(); - unsigned int pkgVersion = getPackageVersion(); - - if (level == 3 && coreVersion == 1 && pkgVersion == 3) - { - attributes.add("xmlns"); - } } /** @endcond */ @@ -482,7 +483,7 @@ ListOfKeyValuePairs::readAttributes(const XMLAttributes& attributes, } } - if (level == 3 && version == 1 && pkgVersion == 3) + if (level == 3 && pkgVersion == 3) { readL3V1V3Attributes(attributes); } @@ -510,7 +511,11 @@ ListOfKeyValuePairs::readL3V1V3Attributes(const XMLAttributes& attributes) // xmlns string (use = "required" ) // - assigned = attributes.readInto("xmlns", mXmlns); + // xmlns is not one of the normal attributes and has to be handled differently + //assigned = attributes.readInto("xmlns", mXmlns); + setXmlns(getNamespaces()); + assigned = !mXmlns.empty(); + if (assigned == true) { @@ -519,16 +524,16 @@ ListOfKeyValuePairs::readL3V1V3Attributes(const XMLAttributes& attributes) logEmptyString(mXmlns, level, version, ""); } } - else - { - if (log) - { - std::string message = "Fbc attribute 'xmlns' is missing from the " - " element."; - log->logPackageError("fbc", FbcKeyValuePairAllowedAttributes, pkgVersion, level, version, - message, getLine(), getColumn()); - } - } + // else + // { + // if (log) + // { + // std::string message = "Fbc attribute 'xmlns' is missing from the " + // " element."; + // log->logPackageError("fbc", FbcKeyValuePairAllowedAttributes, pkgVersion, level, version, + // message, getLine(), getColumn()); + // } + // } } /** @endcond */ @@ -549,7 +554,7 @@ ListOfKeyValuePairs::writeAttributes(XMLOutputStream& stream) const unsigned int version = getVersion(); unsigned int pkgVersion = getPackageVersion(); - if (level == 3 && version == 1 && pkgVersion == 3) + if (level == 3 && pkgVersion == 3) { writeL3V1V3Attributes(stream); } @@ -568,16 +573,29 @@ ListOfKeyValuePairs::writeAttributes(XMLOutputStream& stream) const */ void ListOfKeyValuePairs::writeL3V1V3Attributes(XMLOutputStream& stream) const -{ - if (isSetXmlns() == true) - { - stream.writeAttribute("xmlns", getPrefix(), mXmlns); - } +{ } /** @endcond */ +/* + * Writes the namespace + */ +void +ListOfKeyValuePairs::writeXMLNS(XMLOutputStream& stream) const +{ + + if (mXmlns.empty()) + return; + + XMLNamespaces xmlns; + std::string prefix = getPrefix(); + xmlns.add(mXmlns, prefix); + stream << xmlns; +} + + #endif /* __cplusplus */ diff --git a/src/sbml/packages/fbc/sbml/ListOfKeyValuePairs.h b/src/sbml/packages/fbc/sbml/ListOfKeyValuePairs.h index acb8cf0bbb..83275ad039 100644 --- a/src/sbml/packages/fbc/sbml/ListOfKeyValuePairs.h +++ b/src/sbml/packages/fbc/sbml/ListOfKeyValuePairs.h @@ -170,6 +170,20 @@ class LIBSBML_EXTERN ListOfKeyValuePairs : public ListOf */ int setXmlns(const std::string& xmlns); + /** + * Sets the value of the "xmlns" attribute of this ListOfKeyValuePairs. + * + * @param xmlns XMLNamespaces* value of the "xmlns" attribute to be set. + * @param prefix std::string& optional prefix (defaults to "") + * + * @copydetails doc_returns_one_success_code + * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} + * + * Calling this function with @p xmlns = @c NULL or an empty string is + * equivalent to calling unsetXmlns(). + */ + int setXmlns(const XMLNamespaces* xmlns, const std::string& prefix=""); + /** * Unsets the value of the "xmlns" attribute of this ListOfKeyValuePairs. @@ -502,6 +516,16 @@ class LIBSBML_EXTERN ListOfKeyValuePairs : public ListOf /** @endcond */ + + /** @cond doxygenLibsbmlInternal */ + + /** + * Writes the namespace + */ + virtual void writeXMLNS(XMLOutputStream& stream) const; + + /** @endcond */ + };