0

いくつかの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".

どうすればこれを機能させることができますか?

4

1 に答える 1

0

Of course after posting the question and doing more searching, I found the answer. Here's what I came up with (omitting much of the code from above):

Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
SAXDestination fopDest = new SAXDestination(fop.getDefaultHandler());
.
step2.setDestination(step3);
step3.setDestination(fopDest);

step1.transform();
.
// Output is now in ByteArrayOutputStream out;
于 2013-03-08T17:33:58.320 に答える