[mapguide-internals] Note on MapGuide resource XML documents -
converting between different schema versions
walt.welton-lair at autodesk.com
Tue Mar 10 14:54:32 EDT 2009
I'm currently fixing a MapGuide Studio bug in which the code is not properly converting legacy layer definitions (those saved using schema versions 1.2.0 or earlier) to the latest version. Basically the code was obtaining the legacy XML stream from the MapGuide server and was feeding it into a deserialization class which was expecting version 1.3.0 of the layer definition schema.
A simple way to handle conversions from one version to another is via the open source MdfParser project - it contains all the logic to do the necessary conversion. The process is fairly straightforward:
char* xmlData = ...; // UTF8-encoded XML string
// deserialize into an MdfModel::LayerDefinition
// get the layer and reserialize using the latest schema
MdfModel::LayerDefinition* pLayerDef = parser.DetachLayerDefinition();
std::string xmlDataTranslated = parser.SerializeToXML(pLayerDef, NULL);
// for symbol definitions use the following instead
//MdfModel::SymbolDefinition* pSymbolDef = parser.DetachSymbolDefinition();
//std::string xmlDataTranslated = parser.SerializeToXML(pSymbolDef, NULL);
A good example of the kind of conversion that needs to happen: legacy layer definition XML documents can contain ExtendedData1 elements containing sub-elements that are only supported by later schema versions (see https://trac.osgeo.org/mapguide/wiki/MapGuideRfc10). The MdfParser code processes these ExtendedData1 elements and accounts for them when generating the MdfModel::LayerDefinition. When you re-serialize the layer using the latest schema version the ExtendedData1 elements no longer appear.
Another recent conversion example is this one: https://trac.osgeo.org/mapguide/changeset/3642.
Anyway, since you work on Maestro I just wanted to share that. I'm assuming Maestro allows users to open and edit legacy resources, so it's important that it handles these conversions correctly. I'm also CC'ing 'MapGuide Internals' since this information may be useful to others as well.
W E @__ __o
A T R @___ _ \<,_
L @_ (*)/ (*)
More information about the mapguide-internals