【发布时间】:2015-11-26 20:11:30
【问题描述】:
我们在尝试使用 fop 导出 PDF 时遇到错误:
严重:例外 org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: "fo:list-item" 不是 "fo:list-item-body" 的有效子代! (没有可用的上下文信息) javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "fo:list-item" 不是 "fo:list-item-body" 的有效子代! (没有可用的上下文信息)
据我所知,我们的 XSL 看起来应该可以运行。这是 XSL 的摘录。
<xsl:template match="ol" mode="section-body">
<fo:list-block keep-together="always">
<fo:list-item>
<fo:list-item-label>
</fo:list-item-label>
<fo:list-item-body>
<xsl:apply-templates select="li" mode="section-body" />
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</xsl:template>
<xsl:template match="ul" mode="section-body">
<fo:list-block provisional-distance-between-starts="40mm" content-width="2.5in">
<fo:list-item>
<fo:list-item-label>
</fo:list-item-label>
<fo:list-item-body>
<xsl:apply-templates select="li" mode="section-body"/>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</xsl:template>
<xsl:template match="li" mode="section-body">
<xsl:element name="fo:list-item">
<xsl:if test="position() = last()">
</xsl:if>
<fo:list-item-label>
<xsl:choose>
<xsl:when test="parent::ol">
<xsl:element name="fo:block" use-attribute-sets="list-marker-number"><xsl:value-of select="concat(position(),'.')" /></xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="fo:block" use-attribute-sets="list-marker">•</xsl:element>
</xsl:otherwise>
</xsl:choose>
</fo:list-item-label>
<fo:list-item-body>
<xsl:choose>
<xsl:when test="parent::ol">
<xsl:element name="fo:block" use-attribute-sets="list-item-number">
<xsl:apply-templates mode="section-body"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="fo:block">
<xsl:apply-templates mode="section-body"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</fo:list-item-body>
</xsl:element>
</xsl:template>
【问题讨论】:
标签: java xml apache xsl-fo apache-fop