问题描述
每当我尝试使用 apache fop 1.0 将 .fo 文件转换为 .pdf 时,我都会收到错误引用了实体 0slash 但未声明"
I am getting the error "entity 0slash was referenced but not declared" whenever I try to convert .fo file to .pdf with apache fop 1.0
我发现您可以在 DTD 中声明实体,但是,我的 .fo 文件没有 DTD.它应该有一个吗?如果没有,我该如何解决这个问题?最好不使用额外的 .xsl 或任何文件?
I found out you can declare entities in DTD, however, my .fo file has no DTD. Is it supposed to have one? If not, how can I solve this problem? Prefereably without using additional .xsl or whatever files?
推荐答案
(注意:在我的回答中,我使用的是Oslash"(哦斜线)而不是问题中的0slash"(零斜线). 因为实体名称不能以数字开头,所以我假设零是一个拼写错误.)
(NOTE: In my answer I'm using the "Oslash" (oh slash) instead of the "0slash" (zero slash) you have in your question. Since you can't begin an entity name with a digit, I'm assuming that the zero is a typo.)
您有几个选择:
您可以修改创建 XSL-FO 的任何内容以输出十六进制引用而不是 ISO 实体引用.在这种情况下,
Ø
将是Ø
.
您可以在 DOCTYPE 声明的内部子集中声明实体.
You can declare the entity in the internal subset of a DOCTYPE declaration.
这是添加了 DOCTYPE 的示例 XSL-FO:
Here is a sample XSL-FO with the DOCTYPE added:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fo:root [
<!ENTITY Oslash "Ø">
]>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="page">
<fo:region-body region-name="body"></fo:region-body>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="page">
<fo:flow flow-name="body">
<fo:block>Hello World! Ø</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
如果你用 FOP 处理这个,你会得到:Hello World!Ø
If you process this with FOP, you get: Hello World! Ø
这篇关于fo:引用但未声明的实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!