fo:已引用但未声明的实体 [英] fo: entity referenced but not declared
问题描述
每当我尝试使用apap fop 1.0将.fo文件转换为.pdf时,我都会收到错误消息已引用实体0,但未声明".
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?
推荐答案
(注意:在我的回答中,我使用的是问题中的斜杠"(哦斜杠)而不是"0斜杠"(零斜杠) .由于您不能以数字开头的实体名称,因此我假设零是一个错字.)
(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:已引用但未声明的实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!