1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-18 02:50:09 +03:00

feature #513: More robust XML generation for empty attributes. This may only happen after parsing context attributes

This commit is contained in:
Ruben S. Montero 2011-05-13 00:45:51 +02:00
parent 5bfec3ab96
commit 2a508a112b

View File

@ -75,8 +75,20 @@ string * VectorAttribute::to_xml() const
for (it=attribute_value.begin();it!=attribute_value.end();it++)
{
oss << "<" << it->first << "><![CDATA[" << it->second
<< "]]></"<< it->first << ">";
if ( it->first.empty() )
{
continue;
}
if ( it->second.empty() )
{
oss << "<" << it->first << "/>";
}
else
{
oss << "<" << it->first << "><![CDATA[" << it->second
<< "]]></"<< it->first << ">";
}
}
oss << "</"<< name() << ">";
@ -133,9 +145,16 @@ void VectorAttribute::unmarshall(const string& sattr, const char * _sep)
{
continue;
}
attribute_value.insert(make_pair(tmp.substr(0,mpos),
tmp.substr(mpos+1)));
if ( mpos + 1 == tmp.size() )
{
attribute_value.insert(make_pair(tmp.substr(0,mpos),""));
}
else
{
attribute_value.insert(make_pair(tmp.substr(0,mpos),
tmp.substr(mpos+1)));
}
}
}
/* -------------------------------------------------------------------------- */