[mapguide-users] Fatal Parse error on SetResource

Peter Filip reklamama at centrum.sk
Tue Feb 24 08:47:02 EST 2009


I followed your advice but i get still the same error.

I saved the XML file as UTF-8 without BOM

and i also changed the code

        XmlDocument layerDefinition = new XmlDocument();
       
layerDefinition.Load(System.Web.HttpContext.Current.Server.MapPath(@"xml/layer.xml"));

        UTF8Encoding enc = new UTF8Encoding(false);
        Byte[] byteDef = enc.GetBytes(layerDefinition.ToString());

        MgByteSource bs = new MgByteSource(byteDef, byteDef.Length);
        bs.SetMimeType(MgMimeType.Xml);

        MgResourceIdentifier layerId = new MgResourceIdentifier("Session:" +
mgSessionId + @"//cinnost." + MgResourceType.LayerDefinition);

        resourceService.SetResource(layerId, bs.GetReader(), null);




Kenneth Skovhede, GEOGRAF A/S wrote:
> 
> MapGuide only accepts utf-8 encoded data, with no BOM.
> You must create an encoder for utf-8, and set the BOM generation to false.
> With this encoder, you can get the bytes in the correct format.
> 
> Regards, Kenneth Skovhede, GEOGRAF A/S
> 
> 
> 
> Peter Filip skrev:
>> Hello,
>>
>> i want to create a new layer and save it in the session repository.
>>
>> I use this code:
>>
>>         XmlDocument layerDefinition = new XmlDocument();
>>        
>> layerDefinition.Load(System.Web.HttpContext.Current.Server.MapPath(@"xml/Roads.xml"));
>>
>>         Byte[] byteDef =
>> System.Text.Encoding.Default.GetBytes(layerDefinition.ToString());
>>         MgByteSource bs = new MgByteSource(byteDef, byteDef.Length);
>>         bs.SetMimeType(MgMimeType.Xml);
>>
>>         MgResourceIdentifier layerId = new
>> MgResourceIdentifier("Session:" +
>> mgSessionId + @"//cinnost." +  MgResourceType.LayerDefinition);
>>
>>         resourceService.SetResource(layerId, bs.GetReader(), null);
>>         MgLayer layer = new MgLayer(layerId, resourceService);
>>
>> Error show up on this line
>>
>> resourceService.SetResource(layerId, bs.GetReader(), null);
>>
>> And here is the error message
>>
>>      An exception occurred in DB XML component.
>>         Error: XML Indexer: Fatal Parse error in document at line, 1,
>> char
>> 1. Parser message: Invalid document structure
>>
>>
>> The XML LayerDefinition should be OK. I used the one from Sheyboygan
>> package.
>> I have no idea where's the catch.. Any suggestions??
>>
>>
>>
>>
>>
>>   
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 
> 

-- 
View this message in context: http://n2.nabble.com/Fatal-Parse-error-on-SetResource-tp2377337p2377995.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list