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 Ben Gill <be...@ocado.com> on 2005/03/07 14:48:20 UTC

Error:

Hi,

I downloaded the latest 0.20.5 bin and copied the ExampleObj2PDF example and
am getting:

{ERROR} dao.BaseDAOTestCase  Error generating PDF document
[org.apache.fop.apps.
FOPException: root must be root element]
javax.xml.transform.TransformerException: org.apache.fop.apps.FOPException:
root
 must be root element
        at
org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResul
t.java:725)
        at
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(
ElemApplyTemplates.java:425)
        at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTempla
tes.java:216)
        at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Tr
ansformerImpl.java:2339)
        at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Tran
sformerImpl.java:2160)
        at
org.apache.xalan.transformer.TransformerImpl.transformNode(Transforme
rImpl.java:1213)
        at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:668)
        at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:1129)
        at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:1107)


from XLST stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:fo="http://www.w3.org/1999/XSL/Format" 
	exclude-result-prefixes="fo">
  <xsl:output method="xml" version="1.0" omit-xml-declaration="no"
indent="yes"/>
  <!-- ========================= -->
  <!-- root element: projectteam -->
  <!-- ========================= -->
  <xsl:template match="incident">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="simpleA4" page-height="29.7cm" 
			page-width="21cm" margin-top="2cm"
margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="simpleA4">
        <fo:flow flow-name="xsl-region-body">
          <fo:block font-size="16pt" font-weight="bold"
space-after="5mm">Incident Type: 
			<xsl:value-of select="incident"/>
          </fo:block>
          <fo:block font-size="10pt">
            <fo:table table-layout="fixed">
              <fo:table-column column-width="4cm"/>
              <fo:table-column column-width="4cm"/>
              <fo:table-column column-width="5cm"/>
              <fo:table-body>
                <xsl:apply-templates/>
              </fo:table-body>
            </fo:table>
          </fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>
  <!-- ========================= -->
  <!-- child element: member     -->
  <!-- ========================= -->
<!--
  <xsl:template match="member">
    <fo:table-row>
      <xsl:if test="function = 'lead'">
        <xsl:attribute name="font-weight">bold</xsl:attribute>
      </xsl:if>
      <fo:table-cell>
        <fo:block>
          <xsl:value-of select="name"/>
        </fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block>
          <xsl:value-of select="function"/>
        </fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block>
          <xsl:value-of select="email"/>
        </fo:block>
      </fo:table-cell>
    </fo:table-row>
  </xsl:template>
-->
</xsl:stylesheet>


Can anyone help or tell me how to get more info out of FOP?   (ie. some
DEBUG trace?) or even how to get hold of the generated FO file?

Thanks



This message has been checked for all known viruses by the MessageLabs Virus Control Centre.

	
*********************************************************************

Notice:  This email is confidential and may contain copyright material of Ocado Limited (the "Company"). Opinions and views expressed in this message may not necessarily reflect the opinions and views of the Company.
If you are not the intended recipient, please notify us immediately and delete all copies of this message. Please note that it is your responsibility to scan this message for viruses.

Company reg. no. 3875000.
Ocado Limited
Titan Court
3 Bishops Square
Hatfield Business Park
Hatfield
Herts
AL10 9NE


*********************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: Error:

Posted by Jeremias Maerki <de...@greenmail.ch>.
Do the following: Instead of piping the result of the XSL transformation
through to FOP with the following line:

Result res = new SAXResult(driver.getContentHandler());

...simply serialize the resulting XSL-FO document to a file:

Result res = new StreamResult(new File("C:/Temp/debug.fo"));

Check if the FO file looks right and runs smoothly through FOP.

To debug the whole thing outside of your application you might want to
consider writing the early XML to a file. In this case your code would
look like in [1]. Note the identity transformer instead of an XSL
transformation. In this case you'd have a Result like this:

Result res = new StreamResult(new File("C:/Temp/debug.xml"));

Once you have the XML from your application, you can use xalan.bat, fop.bat
and your stylesheet to debug everything. Once your stylesheet is fixed
you can run the integrated code again that does the full functionality.
The key is to break down the whole process into it parts (creating XML
from your application, transforming using XSLT and formatting using FOP).

[1] http://cvs.apache.org/viewcvs.cgi/xml-fop/examples/embedding/java/embedding/ExampleObj2XML.java?rev=1.4


On 07.03.2005 15:27:21 Ben Gill wrote:
> Thanks Chris,
> 
> This helped me sort out the problem straight away....  The xalan.bat will
> help me a lot in debugging...
> 
> But this is not going to show me anything too useful as I am populating
> Object straight to PDF...
> 
> As the Object to PDF generation process, includes generating the XML and the
> FO syntax (at some point during the processing - I assume at least)... is
> there any way to get this information by switching on some sort of FOP
> debugging?  
> 
> That would be really useful.... (and will probably save me a lot of time!!)
> 
> Cheers
> 
> -----Original Message-----
> From: Chris Bowditch [mailto:bowditch_chris@hotmail.com]
> Sent: 07 March 2005 14:04
> To: fop-user@xml.apache.org
> Subject: Re: Error:
> 
> 
> Ben Gill wrote:
> 
> > Hi,
> > 
> > I downloaded the latest 0.20.5 bin and copied the ExampleObj2PDF example
> and
> > am getting:
> > 
> > {ERROR} dao.BaseDAOTestCase  Error generating PDF document
> > [org.apache.fop.apps.
> > FOPException: root must be root element]
> > javax.xml.transform.TransformerException:
> org.apache.fop.apps.FOPException:
> > root
> >  must be root element
> 
> This is a problem with your XML/XSLT
> 
> <snip/>
> 
> > 
> > from XLST stylesheet:
> > 
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsl:stylesheet version="1.1" 
> > 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> > 	xmlns:fo="http://www.w3.org/1999/XSL/Format" 
> > 	exclude-result-prefixes="fo">
> >   <xsl:output method="xml" version="1.0" omit-xml-declaration="no"
> > indent="yes"/>
> >   <!-- ========================= -->
> >   <!-- root element: projectteam -->
> >   <!-- ========================= -->
> >   <xsl:template match="incident">
> 
> Note, that the element being matched differs from the comment. However, this
> 
> may not be the cause of the problem. Most likely cause is several
> occurrences 
> of element incident in your source XML, resulting in several root elements.
> 
> To determine where mistake is you should generate XSL-FO file by running 
> xalan.bat (in FOP distribution) from command line.
> 
> <snip/>
> 
> Chris
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: fop-user-help@xml.apache.org
> 
> 
> _____________________________________________________________________
> This message has been checked for all known viruses by the 
> MessageLabs Virus Control Centre.
> 
> This message has been checked for all known viruses by the MessageLabs Virus Control Centre.
> 
> 	
> *********************************************************************
> 
> Notice:  This email is confidential and may contain copyright material of Ocado Limited (the "Company"). Opinions and views expressed in this message may not necessarily reflect the opinions and views of the Company.
> If you are not the intended recipient, please notify us immediately and delete all copies of this message. Please note that it is your responsibility to scan this message for viruses.
> 
> Company reg. no. 3875000.
> Ocado Limited
> Titan Court
> 3 Bishops Square
> Hatfield Business Park
> Hatfield
> Herts
> AL10 9NE
> 
> 
> *********************************************************************
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: fop-user-help@xml.apache.org



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: Error:

Posted by Chris Bowditch <bo...@hotmail.com>.
Ben Gill wrote:

> Hi,
> 
> I downloaded the latest 0.20.5 bin and copied the ExampleObj2PDF example and
> am getting:
> 
> {ERROR} dao.BaseDAOTestCase  Error generating PDF document
> [org.apache.fop.apps.
> FOPException: root must be root element]
> javax.xml.transform.TransformerException: org.apache.fop.apps.FOPException:
> root
>  must be root element

This is a problem with your XML/XSLT

<snip/>

> 
> from XLST stylesheet:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.1" 
> 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> 	xmlns:fo="http://www.w3.org/1999/XSL/Format" 
> 	exclude-result-prefixes="fo">
>   <xsl:output method="xml" version="1.0" omit-xml-declaration="no"
> indent="yes"/>
>   <!-- ========================= -->
>   <!-- root element: projectteam -->
>   <!-- ========================= -->
>   <xsl:template match="incident">

Note, that the element being matched differs from the comment. However, this 
may not be the cause of the problem. Most likely cause is several occurrences 
of element incident in your source XML, resulting in several root elements.

To determine where mistake is you should generate XSL-FO file by running 
xalan.bat (in FOP distribution) from command line.

<snip/>

Chris


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org