Titanium JIRA Archive
Alloy (ALOY)

[ALOY-267] Improve Malformed XML error reporting

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusResolved
ResolutionFixed
Resolution Date2012-10-01T19:51:14.000+0000
Affected Version/s2012 Sprint 19
Fix Version/s2012 Sprint 20, Release 3.0.0
ComponentsXML
Labelsnotable
ReporterTony Lukasavage
AssigneeUnknown
Created2012-09-14T07:48:18.000+0000
Updated2018-03-07T22:26:11.000+0000

Description

Problem

ALOY-250 solved the issue of malformed XML and making it abort Alloy compilation. Unfortunately it required a hack-ish workaround to a shortcoming in the xmldom module. Specifically, xmldom only reports a message via console.warn when it encounters malformed XML. It does not abort the parsing, which results in tough-to-debug, unexpected behavior for developers. To remedy, when executing new DOMParser().parseFromString in Alloy, we override console.warn before the call to make it abort the app if encountered, and then set console.warn back to normal afterwards. here's the snippet:
var warn = console.warn;
console.warn = function(msg) {
	exports.die(['Error parsing XML document', msg]);
};
var doc = new DOMParser().parseFromString(string);
console.warn = warn;
Obviously this type of hack should ideally be avoided. it would also be nice if we could get more information other than just the tag names of the XML involved, like perhaps line numbers. In any case, this needs to be revisited and improved. * The hack alternatives ** An issue has been logged for error reporting. Ideally this will be implemented by the owner, but the repository doesn't exactly see a lot of activity. ** fork and modify ourselves and maintain a alloy-specific version of xmldom ** Looks for other xml alternatives, like jsdom (see also, time-consuming)

Update (9/14/2012)

My original logged issue has not yet been commented on: https://github.com/jindw/xmldom/issues/36 but the apparently work is underway: https://github.com/jindw/xmldom/commit/eb17b3af06eae4d7d29c5debe74780e347deb0b3 Will watch progress and keep an eye out for new published version to npm.

Comments

  1. Tony Lukasavage 2012-10-01

    Increased the priority as it turns out some of the bad xmldom error reporting, or lack thereof, can cause freezes in the alloy process. Not ending in error, but instead chewing up resources until it is manually aborted.
  2. Tony Lukasavage 2012-10-01

    Got a few other devs to test more complex apps and all looks good with the xml parsing and new error output.

JSON Source