xmlgraphics-fop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rushabh <rushabh.ajm...@igate.com>
Subject Failed to transform report due to Handler Problem
Date Fri, 16 May 2014 11:04:51 GMT
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 =
			      ().createDocumentHandler(foUserAgent, "application/pdf");
	        	ch = fop.getDefaultHandler();		       
			} catch (Exception e) {
				// TODO Auto-generated catch block
	     	        return ch;	       

*A class that calls above method and transform into PDF or printable format

ContentHandler handler = (ContentHandler)

SAXTransformerFactory tFactory =
            Transformer transformer = tFactory.newTransformer();

            final SAXSource inputSource =
                new SAXSource(this.xmlReader, new
         *   transformer.transform(inputSource, new SAXResult(handler));*

On this line i am getting error like unable to transform : - 

ReportException:Failed to transform report
Caused by:
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

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-report-due-to-Handler-Problem-tp40609.html
Sent from the FOP - Dev mailing list archive at Nabble.com.

View raw message