我使用适用于Microsoft Word的Oracle BI Publisher Add-in创建了一个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转换这样的模板?
答案 0 :(得分:0)
要防止FOP阻塞未知的专有属性,请禁用严格验证:
fopFactory.setStrictValidation(false);
参考:http://xmlgraphics.apache.org/fop/1.1/embedding.html#fop-factory。