"Content is not allowed in prolog" error yet nothing before XML declaration

Well as for #1 I checked my file with xxd , result is shown here:

$ xxd sample.fo 00000000: 3c3f 786d 6c20 7665 7273 696f 6e3d 2231 Test mater 00000030: 6961 6c20 6963 6f6e 7354 6869 7320 746f ial iconsThis to 00000040: 7069 6320 7465 7374 7320 7468 6520 4d61 pic tests the Ma 00000050: 7465 7269 616c 2049 636f 6e73 2e52 4544 terial Icons.RED 00000060: 434f 4d20 4c61 626f 7261 746f 7269 6573 COM Laboratories 00000070: 2c20 496e 632e 0a20 2020 2020 2020 2020 , Inc.. 00000080: 2020 2020 2020 2020 2020 2054 6865 7365 These 00000090: 2061 7265 2074 6865 2074 6573 7473 2066 are the tests f 000000a0: 6f72 2074 6865 204d 4920 4449 5441 3a0a or the MI DITA:. 000000b0: 2020 2020 2020 2020 2020 2020 2020 2020 000000c0: 2020 2020 2020 2020 5465 7374 2074 6865 Test the 000000d0: 2022 6b65 7962 6f61 7264 5f61 7272 6f77 "keyboard_arrow 000000e0: 5f64 6f77 6e22 2069 636f 6e2e 5465 7374 _down" icon.Test 000000f0: 2074 6865 206d 6972 726f 722d 696d 6167 the mirror-imag 00000100: 6520 2272 6570 6c79 2220 6963 6f6e 2e54 e "reply" icon.T 00000110: 6865 2069 636f 6e73 2061 7265 2072 656e he icons are ren 00000120: 6465 7265 6420 696e 2074 6865 204d 6174 dered in the Mat 00000130: 6572 6961 6c49 636f 6e73 2066 6f6e 742e erialIcons font. 00000140: 0a09 0954 6573 7420 2331 3a43 6c69 636b . Test #1:Click 00000150: 2074 6865 203c 666f 3a69 6e6c 696e 6520 the 6f75 7365 www.antennahouse 000001e0: 2e63 6f6d 2f6e 616d 6573 2f58 534c 2f45 .com/names/XSL/E 000001f0: 7874 656e 7369 6f6e 7322 2066 6f6e 742d xtensions" font- 00000200: 6661 6d69 6c79 3d22 4d61 7465 7269 616c family="Material 00000210: 4963 6f6e 7322 3eee 8c93 3c2f 666f 3a69 Icons">. 2069 636f 6e2e 436c 6963 6b20 7468 e> icon.Click th 00000240: 6520 3c66 6f3a 696e 6c69 6e65 2078 6d6c e 000002a0: 3c66 6f3a 696e 6c69 6e65 2078 6d6c 6e73 . 00000320: 859e 3c2f 666f 3a69 6e6c 696e 653e 3c2f ..2069 636f 6e2e fo:inline> icon. 

As for #2, I checked with file :

$ file sample.fo sample.fo: XML 1.0 document, UTF-8 Unicode text, with very long lines 

I can only think of the two instances of the Material Icons font codepoints which are 3-byte UTF-8 characters and seem to be properly encoded, as verified online with this site:

  1. Icon "keyboard_arrow_down" is codepoint e313 which is encoded ee 8c 93
  2. Icon "reply" is codepoint e15e which is encoded ee 85 9e

As the xxd output indicates, my XML header seems valid:

I also tried manually inserting a space after the encoding as suggested in one of the answers to the other questions:

which made no difference. So I am baffled as to the problem, especially given the error code given:

[Fatal Error] sample.fo:1:39: Content is not allowed in prolog. Jul 24, 2018 9:56:34 AM org.apache.fop.cli.Main startFOP SEVERE: Exception org.apache.fop.apps.FOPException: org.xml.sax.SAXParseException; systemId: file:/tmp/sample.fo; lineNumber: 1; columnNumber: 39; Content is not allowed in prolog. javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; systemId: file:/tmp/sample.fo; lineNumber: 1; columnNumber: 39; Content is not allowed in prolog. at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:296) at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:116) at org.apache.fop.cli.Main.startFOP(Main.java:186) at org.apache.fop.cli.Main.main(Main.java:217) Caused by: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; systemId: file:/tmp/sample.fo; lineNumber: 1; columnNumber: 39; Content is not allowed in prolog. at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:502) at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:293) . 3 more Caused by: org.xml.sax.SAXParseException; systemId: file:/tmp/sample.fo; lineNumber: 1; columnNumber: 39; Content is not allowed in prolog. at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485) . 4 more 

Just for completeness, the FO file was generated by Saxon and the PDF attempt from fop-2.2:

$ fop -version FOP Version 2.2 $ fop -fo sample.fo -pdf sample.pdf [Fatal Error] sample.fo:1:39: Content is not allowed in prolog. .