Hide Forgot
Firefox will report an XML validation error of: topic.xml:2: parser error : StartTag: invalid element name <!ENTITY euro "&euro;"> ^ This does not appear to happen in Chrome.
This most likely comes from dummy-docbook.ent
The issue looks to be in the removeXmlPreamble() method. public static String removeXmlPreamble(@NotNull final String xml) { final RegExp regExp = RegExp.compile("^\\s*<\\?[\\s\\S]*?\\?>"); return regExp.replace(xml, ""); } has been changed to public static String removeXmlPreamble(@NotNull final String xml) { final RegExp regExp = RegExp.compile("^\\s*<\\?[\\s\\S]*?\\?>", "g"); return regExp.replace(xml, ""); }
The following error appears now instead using Firefox 25.0: topic.xml:981: parser error : Start tag expected, '<' not found ]> and when using Chrome 31.0.1650.57 no errors appear at all. Tested with version 1.3-SNAPSHOT build 201312020954 and all tests were done in Private/Incognito windows.
The issue was actually the removeDoctypePreamble() method. It now reads: public static String removeDoctypePreamble(@NotNull final String xml) { final RegExp regExp = RegExp.compile("<\\s*!DOCTYPE[\\s\\S]*?\\]>"); return regExp.replace(xml, "").trim(); } The old regex was not picking up the doctype, and therefore not picking up the dummy entities. This meant that two lots of entities were being added to the XML file, which causes the error.
I've done some additional changes as the above doesn't handle cases where no internal entity definitions are defined. It also will remove any sample content that is wrapped in CDATA. As such this is the new remove method: public static String removeDoctypePreamble(@NotNull final String xml) { final RegExp regExp = RegExp.compile("^\\s*(<\\?[\\s\\S]*?\\?>)?\\s*(<\\s*!DOCTYPE[\\s\\S]*?(\\[[\\s\\S]*?\\])?>)", "gm"); return regExp.replace(xml, "$1").trim(); }