I've been using the example files (i.e., xml2pdf.xsl and xslfoRef.xml) provided with the FOP distribution to become acquainted with FOP. Using XSLTInputHandler(), I've generated a pdf with the above files. However, the logic within XSLTInputHandler() results in xml2pdf.xsl not being used in the transformation. The following code was used to generate the pdf file:
xmlFile = File(xmlFileName);
xslFile = File(xslFileName);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Driver driver = new Driver();
InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);
XMLReader parser = inputHandler.getParser();
byte content = out.toByteArray();
I've traced the logic through XSLTInputHandler() and have observed the following:
1) "InputHanlder inputHandler = new XSLTInputHandler(xmlFile, xslFile)" returns an XSLTInputHandler object and initializes the xml and xsl file names within that object.
2) "inputHandler.getParser()" results in the return of a "Trax" parser. When this occurs, "useOldTransform", a flag within XSLTInputHandler that is initialized to false, remains false. (Note: if this parser wasn't available, a SAX parser would be returned and this flag would be reset to true).
3) When "inputHandler.getInputSource()" is then called with useoldTransform set to false, xmlFile is returned as the input source, without XSLTransform.transform() being called to exercise the xmlFile using the xslFile.
The bottom line is that the input source to driver.buildFOTree() is the xml file. To confirm this, I changed the above code to feed the xml file directly to buildFOTree(), with the result being a pdf file that appears identical to the one generated without this modification. It also appears to be identical to xslfoRef.pdf, the sxl:fo short reference that comes with the FOP distribution.
I've also changed XSLTInputHandler.getInputSource() to evoke XSLTransform.transform() regardless of which parser was available, just to see the result. However, I would like to first discuss the situation described above.
Thanks in advance,