0

我使用适用于 Microsoft Word 的 Oracle BI Publisher 插件创建了一个 XSL-FO 模板,我想使用 FOP 对其进行转换,并将其导出为 PDF 文件。

从 Oracle 命名空间中发现第一个标记后,转换操作失败,错误消息显示:

(Location of error unknown)org.apache.fop.fo.ValidationException: Invalid property encountered on "fo:root": xdofo:nf-separator (No context info available)

这是代码:

FopFactory fopFactory = FopFactory.newInstance();
out = new BufferedOutputStream(new FileOutputStream(new File("result.pdf")));
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

StreamSource source = new StreamSource(generateOrderInvoiceXml(orderId));
StreamSource transformSource = new StreamSource(new File("template.xsl"));

TransformerFactory factory = TransformerFactory.newInstance();

Transformer transformer = factory.newTransformer(transformSource);
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(source, res);

有没有办法使用 FOP 转换这样的模板?

4

1 回答 1

0

为防止 FOP 因未知的专有属性而窒息,请禁用严格验证:

fopFactory.setStrictValidation(false);

参考:http: //xmlgraphics.apache.org/fop/1.1/embedding.html#fop-factory

于 2013-07-17T11:56:50.613 回答