[GME-commit] GMESRC/GME/XmlBackEnd CoreXmlFile.cpp,1.10,1.11
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Tue Jun 5 15:26:44 CDT 2007
Update of /project/gme-repository/GMESRC/GME/XmlBackEnd
In directory escher:/tmp/cvs-serv19701
Modified Files:
CoreXmlFile.cpp
Log Message:
Fix for the flattened multiline attributes in case of xmlbackend projects.
See http://escher.isis.vanderbilt.edu/JIRA/browse/GME-151
CVS User: Zoltan Molnar, ISIS (zolmol)
Index: CoreXmlFile.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/CoreXmlFile.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** CoreXmlFile.cpp 2 Jun 2007 16:05:18 -0000 1.10
--- CoreXmlFile.cpp 5 Jun 2007 20:26:42 -0000 1.11
***************
*** 2098,2101 ****
--- 2098,2109 ----
COMTHROW( metaobject->get_Token( &metaToken ) );
guid2str( obj->m_guid, str );
+
+ // the multiline case? for details see Mga\MgaGeneric.cpp
+ // and http://escher.isis.vanderbilt.edu/JIRA/browse/GME-151
+ // those VALTYPE_STRING type of attributes which are shown in the GME
+ // environment as multiline strings are affected: StrValue and RegNodeValue
+ // the objects which own these kinds of attibutes are: StrAttr and RegNode
+ bool spec_care = metaToken == "StrAttr" || metaToken == "RegNode";
+ std::string spec_value;
fprintf(file, "%s<%S MetaId=\"%d\" Id=\"%s\"", prefix, metaToken, obj->m_metaid, str.c_str() );
***************
*** 2136,2139 ****
--- 2144,2150 ----
char buf[200];
sprintf(buf, "%S", attribToken );
+
+ bool spec_attr = spec_care && (attribToken == "StrValue" || attribToken == "RegNodeValue");
+
std::string attribToken2 = buf;
replaceSpaceWithUnderscore(attribToken2);
***************
*** 2142,2149 ****
encodeXMLString( attrVal, encodedAttrVal );
! fprintf(file, " %s=\"%s\"", attribToken2.c_str(), encodedAttrVal.c_str() );
}
}
! fprintf(file, ">\n" );
// write out children
--- 2153,2167 ----
encodeXMLString( attrVal, encodedAttrVal );
! if( spec_attr) // spec_care is also true
! spec_value = attrVal; // store the (possibly multiline) original value, without encoding
! else // regular dump:
! fprintf(file, " %s=\"%s\"", attribToken2.c_str(), encodedAttrVal.c_str() );
}
}
! fprintf(file, ">" );
! if( spec_care) // right after the element, without whitespace, (in sync with readObject())
! fprintf(file, "<![CDATA[%s]]>", spec_value); // encoding not needed since it goes to CDATA
! fprintf(file, "\n" );
!
// write out children
***************
*** 2274,2277 ****
--- 2292,2302 ----
#pragma warning( default: 4244) // conversion from 'long' to 'short', possible loss of data
+ CComBSTR metaobj_token;
+ COMTHROW( metaobject->get_Token( &metaobj_token));
+
+ // the multiline case? ----- for details see writeObject()
+ bool spec_care = metaobj_token == "StrAttr" || metaobj_token == "RegNode";
+ std::string spec_value;
+
// find or create object
XmlObject * obj = NULL;
***************
*** 2310,2313 ****
--- 2335,2357 ----
char * attrVal = XMLString::transcode(e->getAttribute(attribToken));
+ // multiline case?
+ bool spec_attr = spec_care && ( attribToken == "StrValue" || attribToken == "RegNodeValue");
+ if( spec_attr)
+ {
+ // the implementation below with getChildNodes() is more tolerant of XML COMMENTs, XML Whitespaces...
+ // than using the getFirstChild() method, which can be easily tricked by whitespaces
+ DOMNodeList * children = e->getChildNodes();
+ // find the first CDATA section among the kids: it should be the first node! (based on writeObject()'s impl)
+ for( int i = 0; i < (int) children->getLength(); ++i )
+ {
+ DOMNode * node = children->item(i);
+ if( node->getNodeType() == DOMNode::CDATA_SECTION_NODE ) // the first CDATA element is taken
+ {
+ spec_value = XMLString::transcode( ((DOMCDATASection*)node)->getTextContent());
+ break;
+ }
+ }
+ }
+
replaceUnderscoreWithSpace( attrVal );
***************
*** 2327,2330 ****
--- 2371,2377 ----
{
it2->second->fromString(attrVal);
+
+ if( spec_attr) // spec_care is also true
+ it2->second->fromString( spec_value.c_str());
}
***************
*** 2348,2352 ****
{
DOMNode * node = children->item(i);
! if( node->getNodeType() == DOMNode::ELEMENT_NODE )
readObject( (DOMElement*)node, pointers, obj, fullLoad, lastWriteTime );
}
--- 2395,2400 ----
{
DOMNode * node = children->item(i);
! //if spec_care was true the first child was CDATA, but we process anyway the ELEMENTs only
! if( node->getNodeType() == DOMNode::ELEMENT_NODE )
readObject( (DOMElement*)node, pointers, obj, fullLoad, lastWriteTime );
}
More information about the GME-commit
mailing list