我需要将几个 XSL 转换的输出通过管道传输到 FopFactory 对象,但我不知道如何编写代码。我有管道工作,但最后一步是个谜。
DOMResult xmlRequest = new DOMResult();
marshaller.marshal(req,xmlRequest);
FopFactory fopFactory = FopFactory.newInstance();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
ByteArrayOutputStream out = new ByteArrayOutputStream();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
XdmNode source = processor.newDocumentBuilder()
.build(new DOMSource(xmlRequest.getNode()));
XsltTransformer step1 = templateCache.get("foo1.xsl").load();
XsltTransformer step2 = templateCache.get("foo2.xsl").load();
XsltTransformer step3 = templateCache.get("foo3_fo.xsl").load();
step1.setInitialContextNode(source);
step1.setDestination(step2);
step2.setDestination(step3);
// Here's what I really need to do -- pipe the output of step3 into the FO processor.
// Of course, the following statement doesn't work, but I don't know what I need
// to do to make the output of step3 piped into the fop, so the
step3.setDestination(fop.getDefaultHandler());
step1.transform();
// at this point, the results of the FOP processor would be in the
// ByteArrayOutputStream "out".
我怎样才能使这项工作?