You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Pedro Barco Bernal <pb...@ceh.junta-andalucia.es> on 2002/02/06 08:53:57 UTC
ERROR in server
Hi all!
My question is very simple, i want to create a pdf file from a xml file
and a xsl file.
My code is placed in a JSP and i do not know why it doesn´t run fine.
The error i get is: "org.apache.fop.apps.FOPException: Bad file
descriptor" but i´m sure that the xml and xsl are well-formed...
Please, if you know the solution to my problem, answer my question.
Thanks.
This is my code:
/*
* xmlparam,xslparam,pdfparam are the routes of the files placed in my
server-->/u01/oracle/..../xml.xml, xsl.xsl,
*/
File xmlf = new File(xmlparam);
File xslf = new File(xslparam);
File writefile = new File(pdfparam);
writefile.createNewFile();
Driver driver = new Driver();
driver.setRenderer(Driver.RENDER_PDF);
InputHandler inputHandler = new XSLTInputHandler(xmlf, xslf);
XMLReader parser = inputHandler.getParser();
InputSource inputSource = inputHandler.getInputSource();
driver.setOutputStream(new FileOutputStream(writefile));
driver.render(parser, inputSource);
This is my xml (named xml.xml)
<timesheet>
<employee>
<first_name>John</first_name>
<last_name>Doe</last_name>
<dept>5130</dept>
<location>B27</location>
<ext>2819</ext>
<type>XPT</type>
</employee>
</timesheet>
This is my xsl (named xsl.xsl)
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" media-type="text/xml"
indent="yes"/>
<xsl:template match="timesheet">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="only">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-name="only">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates
select="employee"/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="employee">
<fo:block font-size="8pt" font-family="arial"
line-height="10pt">
<xsl:apply-templates select="first_name"/>
<xsl:apply-templates select="last_name"/>
<xsl:apply-templates select="dept"/>
<xsl:apply-templates select="location"/>
<xsl:apply-templates select="ext"/>
<xsl:apply-templates select="type"/>
</fo:block>
</xsl:template>
<xsl:template match="first_name">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</xsl:template>
<xsl:template match="last_name">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</xsl:template>
<xsl:template match="dept">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</xsl:template>
<xsl:template match="location">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</xsl:template>
<xsl:template match="ext">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</xsl:template>
<xsl:template match="type">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</xsl:template>
</xsl:stylesheet>