Opened 16 years ago
Closed 2 years ago
#979 closed defect (fixed)
WebLayout XML must be formatted/indented correctly whereas others (Layer, MapDefinition, Data) do not.
Reported by: | cagray | Owned by: | jng |
---|---|---|---|
Priority: | low | Milestone: | 4.0 |
Component: | AJAX Viewer | Version: | 2.2.0 |
Severity: | trivial | Keywords: | |
Cc: | External ID: |
Description
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.
Change History (9)
comment:1 by , 16 years ago
comment:2 by , 13 years ago
Milestone: | → 2.3 |
---|---|
Version: | 2.1.0 → 2.2.0 |
comment:3 by , 13 years ago
Argument is null.
- MgWebLayout.MgWebLayout() line 47 file c:\builds\mg22win32\mgdev\web\src\webapp\WebLayout.cpp - MgWebLayout.ParseWebLayoutDefinition() line 309 file c:\builds\mg22win32\mgdev\web\src\webapp\WebLayout.cpp - MgWebLayout.ParseCommandSet() line 1731 file c:\builds\mg22win32\mgdev\web\src\webapp\WebLayout.cpp - MgWebLayout.ParseCommand() line 585 file c:\builds\mg22win32\mgdev\web\src\webapp\WebLayout.cpp - MgWebLayout.ParsePrintCommand() line 884 file c:\builds\mg22win32\mgdev\web\src\webapp\WebLayout.cpp
comment:4 by , 12 years ago
Milestone: | 2.3 → 2.4 |
---|
comment:5 by , 12 years ago
Milestone: | 2.4 → 2.5 |
---|
comment:6 by , 12 years ago
Milestone: | 2.5 → 2.6 |
---|
I have seen that Studio chokes with a similar error, which is why Maestro indents the xml.
I have the impression that Studio uses some of the same MapGuide dll's (MdfParser?), which could explain why this issue is also present in the MapGuide code.