本文介绍了“序言中不允许有内容"错误但在

问题描述

首先我已经彻底检查了以下问题,这个问题似乎不是一回事:

First of all I have already exhaustively checked the following questions and this issue does not seem to be the same thing:

这些似乎都归结为两件事:

These all seem to boil down to 2 things:

  1. 在开始的 标记之前有一个或多个(可能是不可见的)字符.
  2. 正文中有一些字节序列不符合 <? 标签中定义的 encoding.
  1. There is one or more (possibly invisible) chars before the opening <? tag.
  2. There is some byte sequence in the body that does not fit the encoding defined in the <? tag.

对于#1,我用xxd 检查了我的文件,结果如下所示:

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  <?

至于#2,我检查了file:

$ file sample.fo
sample.fo: 

我只能想到 Material Icons 字体代码点的两个实例,它们是 3 字节的 UTF-8 字符并且似乎被正确编码,如 通过本网站在线验证:

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. 图标keyboard_arrow_down"是编码为 ee 8c 93
  2. 的代码点 e313
  3. 图标回复"是编码为 ee 85 9e
  4. 的代码点 e15e
  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

正如 xxd 输出所示,我的

As the xxd output indicates, my

<?

我还尝试按照其他问题的一个答案中的建议在编码后手动插入一个空格:

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.

为了完整起见,FO 文件是由 Saxon 和来自 fop-2.2 的 PDF 尝试生成的:

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.
...

推荐答案

错误,

序言中不允许出现内容.

出现是因为 ,它是 ,具有不允许的文本内容.错误不一定发生在之前

arises because the , which is everything before the root element in an , has textual content that is not allowed. The error does not necessarily have to have occurred before the

具体来说,prolog 是在 document:

Specifically, the prolog in document:

[1] document      ::= prolog element Misc*

请注意,prolog 位于 element 之前.

Note that prolog precedes element, the single root element of the

大多数答案都集中在 prolog 的开头、在 prolog 之内或之后:

Most answers focus on the problem where there is text (visible or invisible) at the beginning of the prolog, before the within or after the prolog either:

[22] prolog      ::= 

在您的情况下,您有 Test material... 文本内容出现在 ) 和根元素 (element>).注释、处理指令或空格可以出现在那里,但不能出现文本.

In your case, you have Test material... text content appearing between the ) and the root element (element). A comment, processing instruction, or whitespace can appear there, but not text.

这篇关于“序言中不允许有内容"错误但在

05-27 23:03