Can you show us your FO document?
On 05/16/2014 06:41 AM, rushabh wrote:
I am getting error while running a test case regarding Handler issue.
Can you help me ?
Here is a code :-
*A Method which returns a ContentHandler :-*
protected ContentHandler getRendererAsHandler(
final OutputStream anOutputStream)
throws ReportException
{
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
ContentHandler ch = null;
try {
Fop fop =
fopFactory.newFop(MimeConstants.MIME_PDF,foUserAgent,anOutputStream);
().createDocumentHandler(foUserAgent,
"application/pdf");
ch = fop.getDefaultHandler();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ch;
}
*A class that calls above method and transform into PDF or printable format
:-*
ContentHandler handler = (ContentHandler)
getRendererAsHandler(anOutputStream);
SAXTransformerFactory tFactory =
(SAXTransformerFactory)SAXTransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
final SAXSource inputSource =
new SAXSource(this.xmlReader, new
InputSource(reportStream));
* transformer.transform(inputSource, new SAXResult(handler));*
On this line i am getting error like unable to transform : -
ReportException:Failed to transform report
Caused by:
javax.xml.transform.TransformerException:
org.apache.fop.fo.ValidationException: First element must be the fo:root
formatting object. Found (Namespace URI:
"http://www.xx.com/xx/ReportTemplate", Local Name: "reportTemplate")
instead. Please make sure you're producing a valid XSL-FO document.
On debug i got FOTreeBuilder object instead ContentHandler object , Thats
why i think it caused error, I also tried to type cast it but not working
properly.
I konw it is some silly mistake but i am new to FOP , So can't able to
resolve it.
--
View this message in context:
http://apache-fop.1065347.n5.nabble.com/Failed-to-Transform-Due-to-Handler-Issue-tp40613.html
Sent from the FOP - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org