Opened 9 years ago

Last modified 5 months ago

#979 new defect

WebLayout XML must be formatted/indented correctly whereas others (Layer, MapDefinition, Data) do not.

Reported by: cagray Owned by:
Priority: low Milestone: 3.3
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 (7)

comment:1 Changed 9 years ago by ksgeograf

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.

comment:2 Changed 7 years ago by zspitzer

Milestone: 2.3
Version: 2.1.02.2.0

comment:3 Changed 7 years ago by zspitzer

Argument is null.

comment:4 Changed 6 years ago by jng

Milestone: 2.32.4

comment:5 Changed 6 years ago by jng

Milestone: 2.42.5

comment:6 Changed 5 years ago by jng

Milestone: 2.52.6

comment:7 Changed 5 months ago by jng

Milestone: 3.03.3

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.