std::string SBasePlugin::getURI() const { if (mSBMLExt == NULL) return getElementNamespace(); const std::string &package = mSBMLExt->getName(); const SBMLDocument* doc = getSBMLDocument(); if (doc == NULL) return getElementNamespace(); SBMLNamespaces* sbmlns = doc->getSBMLNamespaces(); if (sbmlns == NULL) return getElementNamespace(); if (package == "" || package == "core") return sbmlns->getURI(); std::string packageURI = sbmlns->getNamespaces()->getURI(package); if (!packageURI.empty()) return packageURI; return getElementNamespace(); }
std::string ASTBasePlugin::getURI() const { if (mSBMLExt == NULL) return getElementNamespace(); const std::string &package = (mSBMLExt != NULL) ? mSBMLExt->getName() : std::string(""); SBMLNamespaces* sbmlns = getSBMLNamespaces(); if (sbmlns == NULL) return getElementNamespace(); if (package == "" || package == "core") return sbmlns->getURI(); std::string packageURI = sbmlns->getNamespaces()->getURI(package); if (!packageURI.empty()) return packageURI; return getElementNamespace(); }
LIBSBML_EXTERN XMLNode getXmlNodeForSBase(const SBase* object) { char* rawsbml = const_cast<SBase*>(object)->toSBML(); SBMLNamespaces *sbmlns = object->getSBMLNamespaces(); XMLNamespaces* xmlns = sbmlns->getNamespaces()->clone(); // in rare cases the above returns a package element with default namespace, however the // XMLNamespaces would then assign the actual default namespace, which is in most cases // the SBML namespace. In that case we adjust the default namespace here ISBMLExtensionNamespaces *extns = dynamic_cast<ISBMLExtensionNamespaces*>(sbmlns); if (extns != NULL) { xmlns->remove(""); xmlns->add(xmlns->getURI(extns->getPackageName()), ""); } XMLNode* tmp = XMLNode::convertStringToXMLNode(rawsbml, xmlns); if (tmp == NULL) return XMLNode(); XMLNode result(*tmp); delete tmp; delete xmlns; free(rawsbml); return result; }