Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 28, 2008, 7:32:17 PM (16 years ago)
Author:
rgrieder
Message:

XML Attribute are case insensitive now. However this does not applay to tags since they refer to actual classes, which are case sensitive.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/core/XMLPort.h

    r2536 r2539  
    182182        ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \
    183183    } \
    184     containername->port((BaseObject*)this, object, xmlelement, mode)
     184    containername->port(static_cast<BaseObject*>(this), object, xmlelement, mode)
    185185
    186186// --------------------
     
    360360            XMLPortParamContainer& port(BaseObject* owner, T* object, Element& xmlelement, XMLPort::Mode mode)
    361361            {
     362                OrxAssert(owner, "XMLPortParamContainer must have a BaseObject as owner.");
    362363                this->owner_ = owner;
    363364                this->parseParams_.object = object;
     
    369370                    try
    370371                    {
    371                         std::string attribute = xmlelement.GetAttribute(this->paramname_);
    372                         if ((attribute.size() > 0) || ((mode != XMLPort::ExpandObject) && this->loadexecutor_->allDefaultValuesSet()))
     372                        if (this->owner_->lastLoadedXMLElement_ != &xmlelement)
     373                        {
     374                            this->owner_->xmlAttributes_.clear();
     375                            // Iterate through the attributes manually in order to make them case insensitive
     376                            Attribute* attribute = xmlelement.FirstAttribute(false);
     377                            while (attribute != 0)
     378                            {
     379                                this->owner_->xmlAttributes_[getLowercase(attribute->Name())] = attribute->Value();
     380                                attribute = attribute->Next(false);
     381                            }
     382                            this->owner_->lastLoadedXMLElement_ = &xmlelement;
     383                        }
     384                        std::map<std::string, std::string>::const_iterator it = this->owner_->xmlAttributes_.find(getLowercase(this->paramname_));
     385                        std::string attributeValue("");
     386                        if (it != this->owner_->xmlAttributes_.end())
     387                            attributeValue = it->second;
     388
     389                        // TODO: Checking the iterator would be better since then we can have strings with value "" as well.
     390                        //       Unfortunately this does not seem to work with the Executor parser yet.
     391                        if ((!attributeValue.empty()) || ((mode != XMLPort::ExpandObject) && this->loadexecutor_->allDefaultValuesSet()))
    373392                        {
    374393                            COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();
    375                             if (this->loadexecutor_->parse(object, attribute, ",") || (mode  == XMLPort::ExpandObject))
     394                            if (this->loadexecutor_->parse(object, attributeValue, ",") || (mode  == XMLPort::ExpandObject))
    376395                                this->parseResult_ = PR_finished;
    377396                            else
Note: See TracChangeset for help on using the changeset viewer.