xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "West, Chris" <cw...@nextrx.com>
Subject Using a Style Sheet with FOP
Date Mon, 20 Aug 2001 16:56:27 GMT
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();
      driver.buildFOTree(parser, inputHandler.getInputSource());
      byte[] content = out.toByteArray();


I've traced the logic through XSLTInputHandler() and have observed the

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

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,

Chris W.

View raw message