xml-to-react icon indicating copy to clipboard operation
xml-to-react copied to clipboard

improve handling of invalid XML documents

Open taveras opened this issue 7 years ago • 2 comments

per @johnkpaul 's suggestion, we should refine the behavior when faced with an invalid XML document.

today, XMLToReact#convert will simply log a warning when supplied with an invalid XML document. it will also log the warning for all xmldom error levels.


Here are a few questions around this:

  • How should we handle the three xmldom error levels (warning, error, fatal)?
  • Should we strictly throw an error when coming across an invalid XML document?
  • Should we have a 'quirks mode' option with forgiving parsing, similar to HTML parsing?
  • If yes to the previous question, should we be in 'quirks mode' by default, and have an opt-in 'strict mode'?

taveras avatar Dec 11 '17 19:12 taveras

My higher order feedback is that whatever decision is made as to the behavior on invalid input is clearly documented and not surprising to a user of this library.

With respect to your questions in particular, I'd say what are the actual needs of Muse? When you have a business user typing their own XML and they make a mistake, which one of these options would you prefer?

Other than clearly documenting, IMHO, you don't need to add any special and extra features just because it's being open sourced.

johnkpaul avatar Dec 18 '17 20:12 johnkpaul

Generic parsing and handling can go here; anything specific to an application should live downstream.

As for whether we throw or simply log errors (and pave over them) could be configurable. My instinct is to throw and let the application decide what to do.

pgoldrbx avatar Dec 19 '17 19:12 pgoldrbx