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 Ian Hendry <ia...@yahoo.com> on 2007/03/01 18:49:03 UTC

problem with FOP set up

Hi,

I guess my setup is wrong - perhaps someone can help? I downloaded and extracted fop-0.93 (fop-current-bin-jdk1.4.zip) to C:\PROGRA~1\APACHE~1\fop-0.93. I copied the jar files from the /lib directory into my CLASSPATH. Then I tried to run FOP from the command line. I tried first to make an FO file using Fop -xml xml.xml -xsl xsl.xsl -foout foo.fo. The FO file is created fine but then when I try and create the PDF from the FO file that FOP has created for me it fails! See below (Also at the foot of the message I have included the contents of my xml, xsl and FOP's FO file)

Thanks in advance for any help, Ian.

C:\PROGRA~1\APACHE~1\fop-0.93>Fop -xml xml.xml -xsl xsl.xsl -foout foo.fo
"C:\PROGRA~1\Java\jre1.5.0_10\bin\java"
C:\PROGRA~1\APACHE~1\fop-0.93>Fop foo.fo foo.pdf
"C:\PROGRA~1\Java\jre1.5.0_10\bin\java"
01-Mar-2007 17:43:30 org.apache.fop.cli.Main startFOP
SEVERE: Exception
javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException:
 Error: First element must be the fo:root formatting object. Found fo:block inst
ead. Please make sure you're producing a valid XSL-FO document.
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:168)
        at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
        at org.apache.fop.cli.Main.startFOP(Main.java:160)
        at org.apache.fop.cli.Main.main(Main.java:191)

---------

javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException:
 Error: First element must be the fo:root formatting object. Found fo:block inst
ead. Please make sure you're producing a valid XSL-FO document.
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(Transf
ormerIdentityImpl.java:501)
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:165)
        at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
        at org.apache.fop.cli.Main.startFOP(Main.java:160)
        at org.apache.fop.cli.Main.main(Main.java:191)
Caused by: org.apache.fop.fo.ValidationException: Error: First element must be t
he fo:root formatting object. Found fo:block instead. Please make sure you're pr
oducing a valid XSL-FO document.
        at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuil
der.java:292)
        at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:185)
        at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(Tra
nsformerIdentityImpl.java:1072)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Sour
ce)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unkn
own Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.s
canRootElementHook(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
Dispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
known Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(Transf
ormerIdentityImpl.java:484)
        ... 4 more
---------
org.apache.fop.fo.ValidationException: Error: First element must be the fo:root
formatting object. Found fo:block instead. Please make sure you're producing a v
alid XSL-FO document.
        at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuil
der.java:292)
        at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:185)
        at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(Tra
nsformerIdentityImpl.java:1072)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Sour
ce)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unkn
own Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.s
canRootElementHook(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
Dispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
known Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(Transf
ormerIdentityImpl.java:484)
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:165)
        at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
        at org.apache.fop.cli.Main.startFOP(Main.java:160)
        at org.apache.fop.cli.Main.main(Main.java:191)


********* END SCREEN DUMP *********

********* INCLUDED FILES  *********
XML.XML
<?xml version="1.0" encoding="UTF-8"?>
<data>
<name>
Krusty the Clown
</name>
<description>
This memo explains why Krusty the Clown is our best customer.
We need to take good care of him from now onwards and make sure
that there are always enough bananas for his pet monkey. 
</description>
</data>
END XML.XML
XSL.XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match="data">
<fo:block>
<xsl:apply-templates select="name"/>
<xsl:apply-templates select="description"/>
</fo:block>
</xsl:template>

<xsl:template match="name"> 
<fo:block font-size="18pt" 
font-family="sans-serif" 
line-height="24pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
text-align="center"
padding-top="3pt">
<xsl:value-of select="."/>
</fo:block> 
</xsl:template>

<xsl:template match="description">
<fo:block font-size="12pt" 
font-family="sans-serif" 
line-height="15pt"
space-after.optimum="3pt"
text-align="justify">
<xsl:value-of select="."/>
</fo:block>
</xsl:template>

</xsl:stylesheet>
END XSL.XSL
FOO.FO
<?xml version="1.0" encoding="UTF-8"?><fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"><fo:block padding-top="3pt" text-align="center" color="white" background-color="blue" space-after.optimum="15pt" line-height="24pt" font-family="sans-serif" font-size="18pt">
Krusty the Clown
</fo:block><fo:block text-align="justify" space-after.optimum="3pt" line-height="15pt" font-family="sans-serif" font-size="12pt">
This memo explains why Krusty the Clown is our best customer.
We need to take good care of him from now onwards and make sure
that there are always enough bananas for his pet monkey. 
</fo:block></fo:block>
END FO.FO
 

Re: [SPAM] problem with FOP set up

Posted by nickleus <ni...@gmail.com>.
fop_exec_command="exec \"$JAVACMD\"
-Djavax.xml.parser.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
$LOGCHOICE $LOGLEVEL -classpath \"$LOCALCLASSPATH\" $FOP_OPTS
org.apache.fop.cli.Main $fop_exec_args"

didn't seem to have any effect...
neither did making a jaxp.properties file..



Andreas L Delmelle wrote:
> 
> On Mar 7, 2007, at 15:51, nickleus wrote:
> 
>> thanks Andreas for the quick reply. where do i define which xml  
>> parser i want
>> to use or which xslt processor to use?
>> i just downloaded the newest version of fop and thought it would  
>> work out of
>> the box in its own little sandbox...
> 
> It should, in theory, if the Java environment is set up to always use  
> compatible bug-free combinations of the SAX/DOM and JAXP API  
> implementations.
> 
> The SAX/DOM implementation or XSLT processor to use can be set via  
> the JAXP System Properties:
> javax.xml.parsers.DocumentBuilderFactory
> javax.xml.parsers.SAXParserFactory
> javax.xml.transform.TransformerFactory
> 
> You can specify the implementations to use by modifying the used java- 
> commandline (maybe in the fop shell script), and add specify  
> overrides via the -D switch.
> 
> For example:
> 
> %JAVA_CMD% - 
> Djavax.xml.parser.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFacto 
> ryImpl ...
> 
> Or you can do this via a jaxp.properties file in your %JAVA_HOME%/lib/ :
> 
> ##example jaxp.properties##
> javax.xml.parser.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactor 
> yImpl
> javax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryIm 
> pl
> ##end example##
> 
> I hope this works as well as it should, even with GNU Classpath...?
> 
> 
> HTH!
> 
> Cheers,
> 
> Andreas
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/problem-with-FOP-set-up-tf3328582.html#a9357798
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: [SPAM] problem with FOP set up

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Mar 7, 2007, at 15:51, nickleus wrote:

> thanks Andreas for the quick reply. where do i define which xml  
> parser i want
> to use or which xslt processor to use?
> i just downloaded the newest version of fop and thought it would  
> work out of
> the box in its own little sandbox...

It should, in theory, if the Java environment is set up to always use  
compatible bug-free combinations of the SAX/DOM and JAXP API  
implementations.

The SAX/DOM implementation or XSLT processor to use can be set via  
the JAXP System Properties:
javax.xml.parsers.DocumentBuilderFactory
javax.xml.parsers.SAXParserFactory
javax.xml.transform.TransformerFactory

You can specify the implementations to use by modifying the used java- 
commandline (maybe in the fop shell script), and add specify  
overrides via the -D switch.

For example:

%JAVA_CMD% - 
Djavax.xml.parser.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFacto 
ryImpl ...

Or you can do this via a jaxp.properties file in your %JAVA_HOME%/lib/ :

##example jaxp.properties##
javax.xml.parser.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactor 
yImpl
javax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryIm 
pl
##end example##

I hope this works as well as it should, even with GNU Classpath...?


HTH!

Cheers,

Andreas

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


Re: [SPAM] problem with FOP set up

Posted by nickleus <ni...@gmail.com>.
thanks Andreas for the quick reply. where do i define which xml parser i want
to use or which xslt processor to use?
i just downloaded the newest version of fop and thought it would work out of
the box in its own little sandbox...


Andreas L Delmelle wrote:
> 
> On Mar 7, 2007, at 13:50, nickleus wrote:
> 
> Hi,
> 
>> i'm also running fop 0.93 and i get that same error even with the  
>> simplest of
>> fo files that have an fo:root...:
>> <snip />
>> running it through fop in linux, ubuntu 6.10:
>> ./fop helloworld.fo helloworld.pdf
>>
>> gives the following errors:
>> <snip />
>> ---------
>>
>> javax.xml.transform.TransformerException:
>> http://xml.org/sax/handlers/LexicalHandler
>>    at
>> org.apache.xalan.transformer.TransformerIdentityImpl.transform 
>> (TransformerIdentityImpl.java:501)
>>    at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java: 
>> 165)
>>    at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
>>    at org.apache.fop.cli.Main.startFOP(Main.java:160)
>>    at org.apache.fop.cli.Main.main(Main.java:191)
>> Caused by: org.xml.sax.SAXNotSupportedException:
>> http://xml.org/sax/handlers/LexicalHandler
>>    at gnu.xml.stream.SAXParser.setProperty(libgcj.so.70)
>>    at
>> org.apache.xalan.transformer.TransformerIdentityImpl.transform 
>> (TransformerIdentityImpl.java:475)
> 
> It seems that this is an incompatibility issue between the used XSLT  
> processor --Xalan in this case-- and the XML parser. Xalan apparently  
> needs support for the LexicalHandler SAX feature. The URI seems to be  
> slightly off though...
> 
>  From the org.xml.sax.ext.LexicalHandler API docs:
> ---
> This is an optional extension handler for SAX2 to provide lexical  
> information about an XML document, such as comments and CDATA section  
> boundaries; XML readers are not required to support this handler, and  
> it is not part of the core SAX2 distribution.
> ...To set the LexicalHandler for an XML reader, use the setProperty  
> method with the propertyId "http://xml.org/sax/properties/lexical- 
> handler". If the reader does not support lexical events, it will  
> throw a SAXNotRecognizedException or a SAXNotSupportedException when  
> you attempt to register the handler.
> ---
> 
> Your options? Either use different XML parser (Xerces instead of the  
> GNU XML parser) or another XSLT processor (Saxon instead of Xalan).
> 
> 
> HTH!
> 
> Cheers,
> 
> Andreas
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/problem-with-FOP-set-up-tf3328582.html#a9354230
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: [SPAM] problem with FOP set up

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Mar 7, 2007, at 13:50, nickleus wrote:

Hi,

> i'm also running fop 0.93 and i get that same error even with the  
> simplest of
> fo files that have an fo:root...:
> <snip />
> running it through fop in linux, ubuntu 6.10:
> ./fop helloworld.fo helloworld.pdf
>
> gives the following errors:
> <snip />
> ---------
>
> javax.xml.transform.TransformerException:
> http://xml.org/sax/handlers/LexicalHandler
>    at
> org.apache.xalan.transformer.TransformerIdentityImpl.transform 
> (TransformerIdentityImpl.java:501)
>    at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java: 
> 165)
>    at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
>    at org.apache.fop.cli.Main.startFOP(Main.java:160)
>    at org.apache.fop.cli.Main.main(Main.java:191)
> Caused by: org.xml.sax.SAXNotSupportedException:
> http://xml.org/sax/handlers/LexicalHandler
>    at gnu.xml.stream.SAXParser.setProperty(libgcj.so.70)
>    at
> org.apache.xalan.transformer.TransformerIdentityImpl.transform 
> (TransformerIdentityImpl.java:475)

It seems that this is an incompatibility issue between the used XSLT  
processor --Xalan in this case-- and the XML parser. Xalan apparently  
needs support for the LexicalHandler SAX feature. The URI seems to be  
slightly off though...

 From the org.xml.sax.ext.LexicalHandler API docs:
---
This is an optional extension handler for SAX2 to provide lexical  
information about an XML document, such as comments and CDATA section  
boundaries; XML readers are not required to support this handler, and  
it is not part of the core SAX2 distribution.
...To set the LexicalHandler for an XML reader, use the setProperty  
method with the propertyId "http://xml.org/sax/properties/lexical- 
handler". If the reader does not support lexical events, it will  
throw a SAXNotRecognizedException or a SAXNotSupportedException when  
you attempt to register the handler.
---

Your options? Either use different XML parser (Xerces instead of the  
GNU XML parser) or another XSLT processor (Saxon instead of Xalan).


HTH!

Cheers,

Andreas


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


Re: [SPAM] problem with FOP set up

Posted by nickleus <ni...@gmail.com>.
i'm also running fop 0.93 and i get that same error even with the simplest of
fo files that have an fo:root...:
<?xml version="1.0" encoding="ISO-8859-1"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
  <fo:simple-page-master master-name="A4">
  </fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
  <fo:flow flow-name="xsl-region-body">
    <fo:block>Hello W3Schools</fo:block>
  </fo:flow>
</fo:page-sequence>
</fo:root>

running it through fop in linux, ubuntu 6.10:
./fop helloworld.fo helloworld.pdf

gives the following errors:
7-Mar-07 1:48:15 PM org.apache.fop.cli.Main startFOP
SEVERE: Exception
javax.xml.transform.TransformerException:
http://xml.org/sax/handlers/LexicalHandler
   at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:168)
   at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
   at org.apache.fop.cli.Main.startFOP(Main.java:160)
   at org.apache.fop.cli.Main.main(Main.java:191)

---------

javax.xml.transform.TransformerException:
http://xml.org/sax/handlers/LexicalHandler
   at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
   at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:165)
   at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
   at org.apache.fop.cli.Main.startFOP(Main.java:160)
   at org.apache.fop.cli.Main.main(Main.java:191)
Caused by: org.xml.sax.SAXNotSupportedException:
http://xml.org/sax/handlers/LexicalHandler
   at gnu.xml.stream.SAXParser.setProperty(libgcj.so.70)
   at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:475)
   ...4 more
caused by org.xml.sax.SAXNotSupportedException:
http://xml.org/sax/handlers/LexicalHandler
   at gnu.xml.stream.SAXParser.setProperty(libgcj.so.70)
   at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:475)
   at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:165)
   at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
   at org.apache.fop.cli.Main.startFOP(Main.java:160)
   at org.apache.fop.cli.Main.main(Main.java:191)


i can create an xslt and run that and an xml through fop and get a pdf, but
if i first output them to an fo and then try to use that fo to create a pdf
i get those errors. wierd. any ideas? thanks in advance for any help anyone
might offer =)

Nick




Andreas L Delmelle wrote:
> 
> On Mar 1, 2007, at 18:49, Ian Hendry wrote:
> 
> Hi,
> 
>> I guess my setup is wrong - perhaps someone can help?
> 
> It doesn't seem to be. The only problem is this:
> 
>> 01-Mar-2007 17:43:30 org.apache.fop.cli.Main startFOP
>> SEVERE: Exception
>> javax.xml.transform.TransformerException:  
>> org.apache.fop.fo.ValidationException:
>>  Error: First element must be the fo:root formatting object. Found  
>> fo:block inst
>> ead. Please make sure you're producing a valid XSL-FO document.
> 
> The FO document you're generating is not valid XSL-FO, as there is no  
> fo:root node. You'll have to adapt your stylesheet so it produces a  
> complete FO document, and not just a fo:block.
> 
> 
> Cheers
> 
> Andreas
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/problem-with-FOP-set-up-tf3328582.html#a9352252
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: problem with FOP set up

Posted by Ian Hendry <ia...@yahoo.com>.
Hi Andreas,

Perfect solution! I modified the XSL as you suggested and boom - PDF produced.

I can't thank you enough, Ian.

Andreas L Delmelle <a_...@pandora.be> wrote: On Mar 1, 2007, at 18:49, Ian Hendry wrote:

Hi,

> I guess my setup is wrong - perhaps someone can help?

It doesn't seem to be. The only problem is this:

> 01-Mar-2007 17:43:30 org.apache.fop.cli.Main startFOP
> SEVERE: Exception
> javax.xml.transform.TransformerException:  
> org.apache.fop.fo.ValidationException:
>  Error: First element must be the fo:root formatting object. Found  
> fo:block inst
> ead. Please make sure you're producing a valid XSL-FO document.

The FO document you're generating is not valid XSL-FO, as there is no  
fo:root node. You'll have to adapt your stylesheet so it produces a  
complete FO document, and not just a fo:block.


Cheers

Andreas

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



Re: problem with FOP set up

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Mar 1, 2007, at 18:49, Ian Hendry wrote:

Hi,

> I guess my setup is wrong - perhaps someone can help?

It doesn't seem to be. The only problem is this:

> 01-Mar-2007 17:43:30 org.apache.fop.cli.Main startFOP
> SEVERE: Exception
> javax.xml.transform.TransformerException:  
> org.apache.fop.fo.ValidationException:
>  Error: First element must be the fo:root formatting object. Found  
> fo:block inst
> ead. Please make sure you're producing a valid XSL-FO document.

The FO document you're generating is not valid XSL-FO, as there is no  
fo:root node. You'll have to adapt your stylesheet so it produces a  
complete FO document, and not just a fo:block.


Cheers

Andreas

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