[mapguide-trac] #979: WebLayout XML must be formatted/indented correctly whereas others (Layer, MapDefinition, Data) do not.

MapGuide Open Source trac_mapguide at osgeo.org
Wed May 6 06:14:34 EDT 2009


#979: WebLayout XML must be formatted/indented correctly whereas others (Layer,
MapDefinition, Data) do not.
---------------------------+------------------------------------------------
   Reporter:  cagray       |       Owner:       
       Type:  defect       |      Status:  new  
   Priority:  low          |   Milestone:       
  Component:  AJAX Viewer  |     Version:  2.1.0
   Severity:  trivial      |    Keywords:       
External_id:               |  
---------------------------+------------------------------------------------
 When creating new resources from a xml string or file using the Web API
 the formatting (newlines/indenting) of the XML does not matter for Data,
 Layer or MapDefinition resources. However for WebLayout resources it does.
 If incorrectly formatted you get:

 Argument is null. Argument is null

 when you try and view it in the AJAX viewer through a web page (not in
 Maestro which works). If you save this resource in Maestro it fixes it as
 it formats the XML.

 I would have thought that the XML in Mapguide should not rely upon the
 indenting etc?

 I resolved this in my .NET application by running the function on the xml
 string:


 {{{
 public static String FormatXMLString(string sUnformattedXML)
 {
         XmlDocument xd = new XmlDocument();
         xd.LoadXml(sUnformattedXML);
         StringBuilder sb = new StringBuilder();
         StringWriter sw = new StringWriter(sb);
         XmlTextWriter xtw = null;
         try
         {
                 xtw = new XmlTextWriter(sw);
                 xtw.Formatting = Formatting.Indented;
                 xd.WriteTo(xtw);
         }
         finally {
                 if (xtw != null)
                         xtw.Close();
                 }
         return sb.ToString();
 }
 }}}


 and setting PreserveWhiteSpace = true on the XMLDocument object which
 reads the XML String/File in before encoding it to UTF8 bytes and
 submitting to MapGuide using SetResource.

 NOTE: My xml does not have a BOM so it is not a UTF-8 encoding issue as
 far as I am aware.

-- 
Ticket URL: <http://trac.osgeo.org/mapguide/ticket/979>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list