[mapguide-internals] Re: Note on MapGuide resource XML documents - converting between different schema versions

Walt Welton-Lair walt.welton-lair at autodesk.com
Wed Mar 11 18:36:19 EDT 2009

Here's another example of how ExtendedData is used.  I have a layer definition containing enhanced stylization elements (CompositeTypeStyle and child elements), and I want to save this to XML using version 1.0.0 of the layer definition schema.  Enhanced stylization wasn't introduced until schema version 1.1.0, so MdfParser will store the enhanced stylization elements underneath an ExtendedData element.  An older version of MapGuide can then read this version 1.0.0 XML data, but it doesn't know about enhanced stylization so it will ignore those elements when processing the ExtendedData.  It could nevertheless make changes to parts of the layer definition that it does understand (e.g. to a VectorScaleRange) and then save the updated 1.0.0 XML data.  MdfParser would preserve the ExtendedData when saving, and a newer version of MapGuide could open the updated XML and once again use the enhanced stylization.  No data was lost during the roundtripping.


-----Original Message-----
From: Tom Fukushima 
Sent: Wednesday, March 11, 2009 6:09 PM
To: MapGuide Internals Mail List; Walt Welton-Lair
Subject: RE: [mapguide-internals] Re: Note on MapGuide resource XML documents - converting between different schema versions

Hi Kenneth,

RFC http://trac.osgeo.org/mapguide/wiki/MapGuideRfc10 describes this.

I could see it used by someone who is testing a sandboxed feature and wants to extend the data; the feature might take a while to implement so they would need to use the extended data for a while (perhaps even over a couple of releases).  Once we are satisfied that we want to put the feature in the project, they fix up the parser and update the version of the schema.  The users in this case would be the developer, and any users who are trying out the feature.

-----Original Message-----
From: mapguide-internals-bounces at lists.osgeo.org [mailto:mapguide-internals-bounces at lists.osgeo.org] On Behalf Of Kenneth Skovhede, GEOGRAF A/S
Sent: Wednesday, March 11, 2009 3:48 PM
To: Walt Welton-Lair
Cc: MapGuide Internals Mail List
Subject: [mapguide-internals] Re: Note on MapGuide resource XML documents - converting between different schema versions

Thanks for the notification.

Would the ExtendedData be used by anyone other than MapGuide developers 
testing new features?

Regards, Kenneth Skovhede, GEOGRAF A/S

Walt Welton-Lair skrev:
> Hi Kenneth,
> 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
> MdfParser::SAX2Parser parser;
> parser.ParseString(xmlData, strlen(xmlData));
> // get the layer and reserialize using the latest schema
> MdfModel::LayerDefinition* pLayerDef = parser.DetachLayerDefinition();
> std::string xmlDataTranslated = parser.SerializeToXML(pLayerDef, NULL);
> delete pLayerDef;
> // 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.
> Thanks,
> Walt
>  W       E         @__   __o
>    A   T   R   @___    _ \<,_
>      L           @_   (*)/ (*)
mapguide-internals mailing list
mapguide-internals at lists.osgeo.org

More information about the mapguide-internals mailing list