[mapguide-users] Change Resource map in layout definition

Jackie Ng jumpinjackie at gmail.com
Tue Feb 3 05:25:19 EST 2009


Perhaps, the XmlDocument stripped out some attributes in the root element
when converting back to raw xml string content.

Check the xml content before and after the modifications and see if there
were things other than the <ResourceID> element that have been changed.

- Jackie


euskalmap wrote:
> 
> Hi,
> I try your method with this code :
> 
> _________________________________________________
> // Create a MgResourceService and call GetResourceContent() on the
> layout's resource id
> MgResourceIdentifier webLayoutId = new MgResourceIdentifier("Library://Ag
> Base/Mpg Urbanisme.WebLayout");
> MgByteReader byteReader = resourceSrvc.GetResourceContent(webLayoutId);
> XmlDocument doc = new XmlDocument();
> String xmlLayoutDef = byteReader.ToString();
> doc.LoadXml(xmlLayoutDef);
> XmlNode parentNode = doc.GetElementsByTagName("ResourceId").Item(0);	
> if (parentNode!=null)
> {
> 	XmlNode mapRessource = doc.SelectSingleNode("/WebLayout/Map/ResourceId");
> 	if (mapRessource != null)
> 	{
>                 // Change the <ResourceID> element of the <Map> to the
> resource id of *
>                 //  the map you're after. 
> 		mapRessource.InnerText = "Session:" + sessionId + "//" + ag_url.Trim() +
> ".MapDefinition";
> 		String xmlString = doc.DocumentElement.OuterXml;
>         	webLayoutId = new MgResourceIdentifier("Session:" + sessionId +
> "//Map_40Seignanx.MapDefinition");
> 		resourceSrvc.SetResource(webLayoutId, new MgByteReader(xmlString,
> "text/xml"), null);
> 	}
> }
> __________________________________________________
> 
> I have (like other users on nabble forum) this message : 
> 
> An exception occurred in the XML parser.
> An exception occurred in the XML parser.
> Exception occurred in method MgResourceContentManager.ValidateDocument at
> line 556 in file
> d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\server\src\services\resource\ResourceContentManager.cpp
> 
> Have you an idea ?
> Thanks
> 
> 
> Jackie Ng wrote:
>> 
>> Create a MgResourceService and call GetResourceContent() on the layout's
>> resource id, which will return the xml content for that web layout.
>> 
>> Change the <ResourceID> element of the <Map> to the resource id of the
>> map you're after. Then save the changes back to that layout's resource id
>> using SetResource()
>> 
>> The next time you load the ajax viewer with that web layout id, it will
>> have the new map.
>> 
>> - Jackie
>> 
>> 
>> euskalmap wrote:
>>> 
>>> Hi
>>> Can i change the resource map in a layout defintion by code ?
>>> If yes who can i find an example?
>>> thanks
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Change-Resource-map-in-layout-definition-tp2168693p2262599.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list