Ejemplo n.º 1
0
/** @cond doxygenLibsbmlInternal */
SBase*
CompSBasePlugin::createObject(XMLInputStream& stream)
{
  SBase*        object = 0;

  const std::string&   name   = stream.peek().getName();
  const XMLNamespaces& xmlns  = stream.peek().getNamespaces();
  const std::string&   prefix = stream.peek().getPrefix();

  const std::string& targetPrefix = (xmlns.hasURI(mURI)) ? xmlns.getPrefix(mURI) : mPrefix;
  
  if (prefix == targetPrefix)
  {
    if ( name == "listOfReplacedElements" ) 
    {
      if (mListOfReplacedElements != NULL)
      {
        getErrorLog()->logPackageError("comp", CompOneListOfReplacedElements, 
          getPackageVersion(), getLevel(), getVersion());
      }
      createListOfReplacedElements();
      object = mListOfReplacedElements;
    
      if (targetPrefix.empty())
      {
        //
        // (NOTE)
        //
        // A top-level element (listOfReplacedElements) of the comp extension is located 
        // in a default namespace, and thus xmlns=".." attribute must be added to 
        // the element.
        // This is done by invoking SBMLDocument::enableDefaultNS() function with 
        // the two arguments (the URI of this package and true value).
        //
        mListOfReplacedElements->getSBMLDocument()->enableDefaultNS(mURI,true);
      }
    }
    if ( name == "replacedBy" ) {
      if (mReplacedBy != NULL)
      {
        if (mSBML != NULL && getErrorLog() != NULL)
        {
          getErrorLog()->logPackageError("comp", CompOneReplacedByElement, 
                          getPackageVersion(), getLevel(), getVersion());
        }
      }
      delete mReplacedBy;

      COMP_CREATE_NS(compns, getSBMLNamespaces());
      mReplacedBy = new ReplacedBy(compns);
      object = mReplacedBy;
      object->connectToParent(getParentSBMLObject());
      delete compns;
    }
  }
  return object;
}
Ejemplo n.º 2
0
/** @cond doxygenLibsbmlInternal */
SBase* 
SBaseRef::createObject (XMLInputStream& stream)
{
  SBase*        object = NULL;

  const std::string&   name   = stream.peek().getName();
  const XMLNamespaces& xmlns  = stream.peek().getNamespaces();
  const std::string&   prefix = stream.peek().getPrefix();

  const std::string& targetPrefix = (xmlns.hasURI(mURI)) ? xmlns.getPrefix(mURI) : getPrefix();
  
  if (prefix == targetPrefix)
  {
    SBMLErrorLog* errlog = getErrorLog();
    if (mSBaseRef != NULL && (name =="sBaseRef" || name=="sbaseRef")) {
      if (errlog != NULL) {
          errlog->logPackageError(getPackageName(), CompOneSBaseRefOnly, 
            getPackageVersion(), getLevel(), getVersion());
      }
      object = mSBaseRef;
    }
    else if ( name == "sBaseRef" ) {
      COMP_CREATE_NS(compns, getSBMLNamespaces());
      mSBaseRef = new SBaseRef(compns);
      object = mSBaseRef;
      object->connectToParent(this);
      delete compns;
    }
    else if ( name == "sbaseRef" ) {
      if (errlog != NULL) {
          errlog->logPackageError(getPackageName(), CompDeprecatedSBaseRefSpelling, 
            getPackageVersion(), getLevel(), getVersion());
      }
      COMP_CREATE_NS(compns, getSBMLNamespaces());
      mSBaseRef = new SBaseRef(compns);
      object = mSBaseRef;
      object->connectToParent(this);
      delete compns;
    }
  }
  return object;
}