如何在不破坏pdf下载的情况下从xsl文件中删除标题

时间:2016-01-28 17:15:44

标签: python xml pdf xslt xsl-fo

我想删除此Estimated标题和下面的黑线。我试过删除

                <fo:block text-align="center" padding-left="4pt" margin-left="4pt" margin-bottom="4pt" padding-bottom="4pt">
                <xsl:attribute name="border-bottom-color">black</xsl:attribute>
                <xsl:attribute name="border-bottom-width">0.7pt</xsl:attribute>
                <xsl:attribute name="border-bottom-style">solid</xsl:attribute>

                    Estimated
                </fo:block>

('Unable to generate PDF.', 
b'Exception\norg.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: 
"fo:table-cell" is missing child elements. Required content model: marker* (%block;)+ (See position 8:104)
javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException:
 "fo:table-cell" is missing child elements. Required content model: marker* (%block;)+ (See position 48:104)')

尝试删除单词&#34; Estimated&#34;,

甚至尝试删除黑条:

                <xsl:attribute name="border-bottom-color">black</xsl:attribute>
                <xsl:attribute name="border-bottom-width">0.7pt</xsl:attribute>
                <xsl:attribute name="border-bottom-style">solid</xsl:attribute>

('Unable to generate PDF.', b'Exception\norg.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: 
The column-number or number of cells in the row overflows the number of fo:table-columns specified for the table. (See position 25:15)
javax.xml.transform.TransformerException: 
org.apache.fop.fo.ValidationException: The column-number or number of cells in the row overflows the number of fo:table-columns specified for the table. (See position 25:15)\n\n')

Unable to generate PDF部分是自定义的

这个xsl-fo的东西非常挑剔,有谁知道为什么我不能在没有爆炸的情况下移除这些碎片中的一个?谢谢

https://gist.github.com/codyc4321/d8b50adfb9fd1686355e

enter image description here

1 个答案:

答案 0 :(得分:2)

如果您每次都显示删除的内容,则删除整个fo:block会留下一个没有内容的fo:table-cell。 &#34;标记*(%block;)+&#34;告诉您fo:table-cell预计会有一个或多个块级FO(跟随零或多fo:marker)。

您的第二个问题可能与删除属性无关。 FOP可能在检查了FO的内容后检查了表格布局。第一个示例中的错误位置与第二个示例中的错误消息的位置非常不同。检查它告诉你的那条线。

如果你想在让FOP抱怨它之前检查你的FO,https://github.com/AntennaHouse/focheck会找到你的空表格单元格,但它不会检查表格布局。

顺便说一句,您的三个xsl:attribute只能使用border