fo: entity referenced but not declared

我的梦境 提交于 2019-12-02 01:28:22

问题


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

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?


回答1:


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

You have a couple of options:

  1. You can modify whatever is creating your XSL-FO to output hex references instead of the ISO entity references. In this instance Ø would be Ø.

  2. You can declare the entity in the internal subset of a DOCTYPE declaration.

Here is a sample XSL-FO with the DOCTYPE added:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fo:root [
<!ENTITY Oslash "&#xD8;">
]>
<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! &Oslash;</fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

If you process this with FOP, you get: Hello World! Ø



来源:https://stackoverflow.com/questions/6044050/fo-entity-referenced-but-not-declared

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!