[mapguide-users] create a temporary !Mapdefinition and add a layer

Arnaud De Groof Arnaud.DeGroof at spacebel.be
Mon Dec 22 04:20:46 EST 2008


The error log contains the following message: 

 

<2008-12-22T10:10:38>                          Administrator

 Error: An exception occurred in the XML parser.

 StackTrace:

  - MgResourceServiceHandler.ProcessOperation line 80 file d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\server\src\services\resource\ResourceServiceHandler.cpp

  - MgOpSetResource.Execute line 103 file d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\server\src\services\resource\OpSetResource.cpp

  - MgServerResourceService.SetResource line 713 file d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\server\src\services\resource\ServerResourceService.cpp

  - MgRepositoryManager.SetResource line 867 file d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\server\src\services\resource\RepositoryManager.cpp

  - MgRepositoryManager.AddResource line 840 file d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\server\src\services\resource\RepositoryManager.cpp

  - MgResourceContentManager.AddResource line 183 file d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\server\src\services\resource\ResourceContentManager.cpp

  - MgResourceContentManager.PutDocument line 624 file d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\server\src\services\resource\ResourceContentManager.cpp

  - MgResourceDefinitionManager.PutDocument line 554 file d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\server\src\services\resource\ResourceDefinitionManager.cpp

  - MgResourceDefinitionManager.ValidateDocument line 429 file d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\server\src\services\resource\ResourceDefinitionManager.cpp

  - MgResourceContentManager.ValidateDocument line 556 file d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\server\src\services\resource\ResourceContentManager.cpp An exception occurred in the XML parser.

 

Kind regards,

 

Arnaud De Groof

 

________________________________

From: mapguide-users-bounces at lists.osgeo.org [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Kenneth Skovhede, GEOGRAF A/S
Sent: lundi 22 décembre 2008 9:39
To: MapGuide Users Mail List
Subject: Re: [mapguide-users] create a temporary !Mapdefinition and add a layer

 

That is likely an Xml validation error.
It can occur if the Xsd has changed, or one of your attribute values are invalid.

What does the MapGuide error log state?
(On windows, look in C:\Program Files\MapGuideOpenSource2.0\Server\Logs\Error.log)

Regards, Kenneth Skovhede, GEOGRAF A/S



Arnaud De Groof skrev: 

Hi,

 

According to the codes samples (http://trac.osgeo.org/mapguide/wiki/CodeSamples), I try to use the PHP code samples to add a layer to the initial map. 

I carried out the below code but it seems that "$resourceService->SetResource($sessionResourceId, $byteSource->GetReader(), null);" encounters an error in the code.


<?php

include "../../mapviewerphp/constants.php";
include "../../mapviewerphp/common.php";
 
// Initialize
    MgInitializeWebTier($webconfigFilePath);
    $args = ($_SERVER['REQUEST_METHOD'] == "POST") ? $_POST : $_GET;
    $sessionId = $args['SESSION'];
    $mapName = $args['MAPNAME'];
    $layerName1 = 'YYY';
    
    $userInfo = new MgUserInformation($sessionId);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
 
    $wl = "Library://XXX/XXX.WebLayout"; // TODO Constant!
 
// Build a string pointing to the new layer in the Session
    $rlLayerResourceId = "Session:$sessionId//$layerName1.LayerDefinition";
 
// Read the XML of the Library Map Definition
   $md ="Library://XXX/$mapName.MapDefinition";
   $mdResourceId = new MgResourceIdentifier($md);  
   $mdReader = $resourceService->GetResourceContent($mdResourceId);
   $mdXml = $mdReader->ToString();
   $mdDomDoc = DOMDocument::loadXML($mdXml); 
 
// Create the MapLayer XML nodeset in the first position
   $targetNode = $mdDomDoc->getElementsByTagName("MapLayer")->item(0);
   $newNode = $targetNode->parentNode->insertBefore(new DOMElement("MapLayer"), $targetNode); 
   $newNode->appendChild($mdDomDoc->createElement("Name", $layerName1));
   $newNode->appendChild($mdDomDoc->createElement("ResourceId", $rlLayerResourceId));
   $newNode->appendChild($mdDomDoc->createElement("Selectable", "false"));
   $newNode->appendChild($mdDomDoc->createElement("ShowInLegend", "false"));
   $newNode->appendChild($mdDomDoc->createElement("LegendLabel"));
   $newNode->appendChild($mdDomDoc->createElement("ExpandInLegend", "false"));
   $newNode->appendChild($mdDomDoc->createElement("Visible", "true"));
   $newNode->appendChild($mdDomDoc->createElement("Group"));
 
// Write the XML out to form the Session Map Definition
   $updatedXml = $mdDomDoc->saveXML();
   $byteSource = new MgByteSource($updatedXml, strlen($updatedXml));
 
// Create a web layout in the session to hold the updated version
// from the library.
   $sessionMapName = $mdResourceId->GetName();
   $sessionWebLayout = "Session:$sessionId//$sessionMapName.WebLayout";
   $sessionResourceId = new MgResourceIdentifier($sessionWebLayout);
 
// Write the updated web layout to the session.
   $resourceService->SetResource($sessionResourceId, $byteSource->GetReader(), null);
 
// Redirect to the Ajax viewer pointing at the map at the desired coordinates.
   $redirectTo = "mapguide/mapviewerajax/?WEBLAYOUT=$sessionWebLayout&SESSION=$sessionId";
   $host = $_SERVER["HTTP_HOST"];
   $url = "http://$host/$redirectTo" <http://$host/$redirectTo> ;
 
 
// Redirect!
   header("Location: $url");
   exit;
 
//Test
   $f = 'exemple.txt';
   $handle = fopen($f,"w");
   fwrite($handle, "test0: <".$sessionId.">\r\ntest1 :<".$wl.">\r\ntest2 :<".$rlLayerResourceId.">\r\ntest3 :<".$md.">\r\ntestxml :<".$mdXml.">\r\ntest4 :<".$layerName1.">\r\ntestxml1 :<".$updatedXml.">\r\ntest6 :<".$sessionMapName.">\r\ntest5 :<".$sessionWebLayout.">\r\ntest6 :<".$host.">\r\ntest7 :<".$redirectTo.">");
   fclose($handle);

?>

Please would you like to help me to resolve the following issue?
 
Thanks,
 
Arnaud De Groof
________________________________

size=2 width="100%" align=center> 

E-MAIL DISCLAIMER

The present message may contain confidential and/or legally privileged information. If you are not the intended addressee and in case of a transmission error, please notify the sender immediately and destroy this E-mail. Disclosure, reproduction or distribution of this document and its possible attachments is strictly forbidden.

SPACEBEL denies all liability for incomplete, improper, inaccurate, intercepted, (partly) destroyed, lost and/or belated transmission of the current information given that unencrypted electronic transmission cannot currently be guaranteed to be secure or error free.
Upon request or in conformity with formal, contractual agreements, an originally signed hard copy will be sent to you to confirm the information contained in this E-mail.

SPACEBEL denies all liability where E-mail is used for private use.

SPACEBEL cannot be held responsible for possible viruses that might corrupt this message and/or your computer system.

________________________________

 



________________________________



 
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20081222/32e54f3c/attachment.html


More information about the mapguide-users mailing list