使用apache fop创建pdf时在xsl样式表中出现问题

时间:2017-01-13 11:54:53

标签: xslt xsl-fo apache-fop

我想使用Apache FOP将html文档转换为pdf。我试过https://blogs.oracle.com/chrisf/entry/converting_html_to_pdf_using可以正常使用基本的html文件。 但是当页面有一个正确的对齐段落时,这将不起作用

(Location of error unknown)org.apache.fop.fo.ValidationException: First element must be the fo:root formatting object. Found (Namespace URI: "http://www.w3.org/1999/xhtml", Local Name: "html") instead. Please make sure you're producing a valid XSL-FO document.

我尝试创建一个简单的xsl文件,但收到以下错误

  <?xml version="1.0" encoding="utf-8" standalone="no" ?>
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" encoding="utf-8" indent="yes" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
    <xsl:template match="/">
        <xsl:element name="html">
            <xsl:attribute name="xmlns">http://www.w3.org/1999/xhtml</xsl:attribute>
            <xsl:element name="head">
                <xsl:element name="meta">
                    <xsl:attribute name="equiv">content-type</xsl:attribute>
                    <xsl:attribute name="content">text/html;charset=utf-8</xsl:attribute>
                </xsl:element>
                <xsl:element name="title">
                    Happy
                </xsl:element>
            </xsl:element>
            <xsl:element name="body">
                <p style= "font-size: 10px;margin: 5px 0px 20px; padding: 0px 20px 0px 0px; line-height: 130%;
                                  max-width: 258px;">
                    <b>Accounts Payable</b><br/>
                    $Description <br/>
                    $address_line1 $address_line2<br/>
                    $address_city, $address_state $address_zip <br/>
                    $address_country <br/>
                </p>
            </xsl:element>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

请找到我创建的xsl文件。

ModelMapper

0 个答案:

没有答案
相关问题