6.15. 问题和回答

关于问题和解答,此处涉及到几个关键字:

下面直接列出相关示例代码:

例 6.35. 举例:问题和解答qanda相关的示例代码


<qandaset>

    <qandaentry xml:id="qa.property_id_previously_used">
        <question>
            <para>ValidationException: Property ID xxx previously used</para>
        </question>
        <answer>
            <screen>javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Property ID "ref.ldr_syntax" (found on "fo:block") previously used; ID values must be unique within a document! (See position 1315:169)</screen>
            <para>很常见的问题,即源码中,某个id的值,和之前的重复了。</para>
            <para>常出现于,从别处拷贝了某段代码,然后修改完毕后,残留部分内容,导致其中有重复的id</para>
            <para>解决办法:将重复的id删除或者改名</para>
        </answer>
    </qandaentry>

    <qandaentry xml:id="qa.not_a_valid_child">
        <question>
            <para>ValidationException: xxx is not a valid child of xxx</para>
        </question>
        <answer>
            <screen>javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}list-item" is not a valid child of "fo:block"! (See position 345:1605)</screen>
            <para>错误的根本原因是:非正确地使用了某个标签。</para>
            <para>比如某个元素不是另一个元素的子元素,但却由于不熟悉,而误用了。</para>
            <para>但是具体的表现形式,那可能是多种多样的。</para>
            <para>下面就简单列举一下,我所遇到过的错误的例子:</para>
            <orderedlist>
                <listitem>在callout中使用了qandaentry
                    <para>结果导致此错误。然后去官网查了下:<link xl:href="http://www.docbook.org/tdg/en/html/qandaentry.html">qandaentry</link>,才得知,qandaentry的父标签,只包含三种:answer, qandadiv, qandaset。所以,此处在callout中使用qandaentry,肯定会出错了。</para>
                    <para>解决办法:不使用该标签,或者换一个合法的位置使用该标签。</para>
                </listitem>
                <listitem>在part下,title和chapter之间,使用了para
                    <para>结果导致报错:</para>
                    <screen>org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}block" is not a valid child of "fo:root"!</screen>
                    <para>后来是删除了para,才去掉此错误的。</para>
                    <para>详情参考:<link xl:href="http://www.crifan.com/fop_error_validationexception_block_not_a_valid_child_of_fo_root/">【已解决】org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: "{http://www.w3.org/1999/XSL/Format}block" is not a valid child of "fo:root"!</link></para>
                </listitem>
            </orderedlist>
        </answer>
    </qandaentry>

</qandaset>