Default XSL Stylesheet for PDF?
Hi All, I'm working on Ubuntu 10.04 (x64). I installed the FOP package, and now trying to create a PDF from O'Reilly's DocBook sample at https://prod.oreilly.com/external/tools/docbook/docs/authoring/docbook_source/. $oreilly-handbook$ fop -xml book.xml -pdf book.pdf results in an exception: Oct 25, 2011 3:34:41 AM org.apache.fop.cli.Main startFOP SEVERE: Exception org.apache.fop.apps.FOPException: XSLT file must be specified for the transform mode I believe i need to add `-xsl stylesheet`. But I don't know what the default stylesheet is. Would anyone be able to point out the default PDF stylesheet? Thanks in advance, Jeff - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
Re: Default XSL Stylesheet for PDF?
Hi Jeff, FOP is an FO processor, as such it takes FO as input, not XML (even though FO is XML, XML isn't FO). You need to make sure your input is valid FO, then either use the -fo parameter or no parameter since it's the FOPs primary input. If you were curious the -xml input is used in conjunction with an XSLT (thus the -xsl parameter) to transform said XML file to FO. There is no default PDF stylesheet, this mechanism is merely a helper since a lot of users create FO using a transform. So assuming your book.xml is valid FO, the command would look like: $oreilly-handbook$ fop book.xml -pdf book.pdf Hope that helps Mehdi On 25 October 2011 08:37, Jeffrey Walton noloa...@gmail.com wrote: Hi All, I'm working on Ubuntu 10.04 (x64). I installed the FOP package, and now trying to create a PDF from O'Reilly's DocBook sample at https://prod.oreilly.com/external/tools/docbook/docs/authoring/docbook_source/. $oreilly-handbook$ fop -xml book.xml -pdf book.pdf results in an exception: Oct 25, 2011 3:34:41 AM org.apache.fop.cli.Main startFOP SEVERE: Exception org.apache.fop.apps.FOPException: XSLT file must be specified for the transform mode I believe i need to add `-xsl stylesheet`. But I don't know what the default stylesheet is. Would anyone be able to point out the default PDF stylesheet? Thanks in advance, Jeff - 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
Re: Default XSL Stylesheet for PDF?
On Tue, Oct 25, 2011 at 3:48 AM, mehdi houshmand med1...@gmail.com wrote: Hi Jeff, FOP is an FO processor, as such it takes FO as input, not XML (even though FO is XML, XML isn't FO). You need to make sure your input is valid FO, then either use the -fo parameter or no parameter since it's the FOPs primary input. OK, thanks (I think). If you were curious the -xml input is used in conjunction with an XSLT (thus the -xsl parameter) to transform said XML file to FO. There is no default PDF stylesheet, this mechanism is merely a helper since a lot of users create FO using a transform. OK. xalan also complains about a style sheet. These style sheets seem important. $ xalan -in book.xml XSLT Error: Failed to process stylesheet. (line -1, column -1.) XSLException Type is: XSLTProcessorException Message is: Failed to process stylesheet. (Unknown URI, line -1, column -1) So assuming your book.xml is valid FO, the command would look like: $oreilly-handbook$ fop book.xml -pdf book.pdf OK, thanks. Out of curiosity, how do you create a PDF from a XML (DocBook) book. I haven't had any luck with docbook2pdf, xsltproc, xalan, fop, etc. I am amazed at how difficult the designers/architects have made this process. Here's what the sample book looks like (the chapters are similar): ?xml version=1.0 encoding=UTF-8? !DOCTYPE book PUBLIC -//OASIS//DTD DocBook XML V4.4//EN http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd; book titleDocBook Authoring Guidelines/title xi:include href=bookinfo.xml xmlns:xi=http://www.w3.org/2001/XInclude; / xi:include href=ch00.xml xmlns:xi=http://www.w3.org/2001/XInclude; / xi:include href=ch01.xml xmlns:xi=http://www.w3.org/2001/XInclude; / xi:include href=ch02.xml xmlns:xi=http://www.w3.org/2001/XInclude; / xi:include href=ch03.xml xmlns:xi=http://www.w3.org/2001/XInclude; / /book Jeff $ fop book.xml -pdf book.pdf Oct 25, 2011 3:48:53 AM org.apache.fop.cli.Main startFOP SEVERE: Exception org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: book) instead. Please make sure you're producing a valid XSL-FO document. javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: book) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:217) at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:125) at org.apache.fop.cli.Main.startFOP(Main.java:166) at org.apache.fop.cli.Main.main(Main.java:197) Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: book) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:502) at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:214) ... 3 more Caused by: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: book) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:262) at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:163) at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1073) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source) at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 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.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485) ... 4 more - javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException:
RE: Default XSL Stylesheet for PDF?
Jeff, Despite your question is more about Docbook specific points, than FOP, I'll try to give you an idea. If you are using Docbook, try the following 2-step transformation. 1. Use xsltproc to create a FO file using default Docbook: xsltproc --xinclude --output book.fo path_to_your_docbook_xsl_stylesheets/docbook-xsl-1.76.1/fo/docbook.xsl book.xml As a result you will get .fo-file: book.fo 2. Using FOP try to create PDF: fop book.fo book.pdf Hope this helps. P.S. If you are using Windows OS, replace the slash to the opposite one (sorry, but I forgot about what slash is reverse and what is normal). -- Best regards, Eduard Tibet -Original Message- From: Jeffrey Walton [mailto:noloa...@gmail.com] Sent: Tuesday, October 25, 2011 11:55 AM To: mehdi houshmand Cc: fop-users@xmlgraphics.apache.org Subject: Re: Default XSL Stylesheet for PDF? On Tue, Oct 25, 2011 at 3:48 AM, mehdi houshmand med1...@gmail.com wrote: Hi Jeff, FOP is an FO processor, as such it takes FO as input, not XML (even though FO is XML, XML isn't FO). You need to make sure your input is valid FO, then either use the -fo parameter or no parameter since it's the FOPs primary input. OK, thanks (I think). If you were curious the -xml input is used in conjunction with an XSLT (thus the -xsl parameter) to transform said XML file to FO. There is no default PDF stylesheet, this mechanism is merely a helper since a lot of users create FO using a transform. OK. xalan also complains about a style sheet. These style sheets seem important. $ xalan -in book.xml XSLT Error: Failed to process stylesheet. (line -1, column -1.) XSLException Type is: XSLTProcessorException Message is: Failed to process stylesheet. (Unknown URI, line -1, column -1) So assuming your book.xml is valid FO, the command would look like: $oreilly-handbook$ fop book.xml -pdf book.pdf OK, thanks. Out of curiosity, how do you create a PDF from a XML (DocBook) book. I haven't had any luck with docbook2pdf, xsltproc, xalan, fop, etc. I am amazed at how difficult the designers/architects have made this process. Here's what the sample book looks like (the chapters are similar): ?xml version=1.0 encoding=UTF-8? !DOCTYPE book PUBLIC -//OASIS//DTD DocBook XML V4.4//EN http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd; book titleDocBook Authoring Guidelines/title xi:include href=bookinfo.xml xmlns:xi=http://www.w3.org/2001/XInclude; / xi:include href=ch00.xml xmlns:xi=http://www.w3.org/2001/XInclude; / xi:include href=ch01.xml xmlns:xi=http://www.w3.org/2001/XInclude; / xi:include href=ch02.xml xmlns:xi=http://www.w3.org/2001/XInclude; / xi:include href=ch03.xml xmlns:xi=http://www.w3.org/2001/XInclude; / /book Jeff $ fop book.xml -pdf book.pdf Oct 25, 2011 3:48:53 AM org.apache.fop.cli.Main startFOP SEVERE: Exception org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: book) instead. Please make sure you're producing a valid XSL-FO document. javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: book) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:217) at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:125) at org.apache.fop.cli.Main.startFOP(Main.java:166) at org.apache.fop.cli.Main.main(Main.java:197) Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: book) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:502) at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:214) ... 3 more Caused by: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: book) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:262) at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:163) at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1073) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source) at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl
Re: Default XSL Stylesheet for PDF?
Hi Jeffrey, p, li { white-space: pre-wrap; } On Tuesday 25 October 2011 Jeffrey Walton wrote: [...] If you were curious the -xml input is used in conjunction with an XSLT (thus the -xsl parameter) to transform said XML file to FO. There is no default PDF stylesheet, this mechanism is merely a helper since a lot of users create FO using a transform. OK. xalan also complains about a style sheet. These style sheets seem important. They are not important, they are essential! :-) $ xalan -in book.xml XSLT Error: Failed to process stylesheet. (line -1, column -1.) You miss a -xsl option. If you do not know how to run xalan, use the -h or --help option to display an overview. There it should give you an idea what options xalan needs. XSLException Type is: XSLTProcessorException Message is: Failed to process stylesheet. (Unknown URI, line -1, column -1) You miss one point: Xalan complains correctly so as you forgot to add a XSLT stylesheet. I'm not that familiar with Xalan, so I usually use xsltproc. Here is an example: $ DB=/usr/share/xml/docbook/stylesheet/nwalsh/current/ $ xsltproc --output book.fo $DB/fo/docbook.xsl book.xml The basic principle is the same regardless of the XSLT processor. Let me explain these two lines: The first line is just a convenience variable. You need to change that path to point to your DocBook XSL stylesheets. Search for a package with docbook-xsl or the like. Just add the _path_. The second line is the transformation. It needs the XSLT stylesheet which is $DB/fo/docbook.xsl as one input and your DocBook XML document book.xml as another input. The result of the transformation is saved in book.fo. Out of curiosity, how do you create a PDF from a XML (DocBook) book. I haven't had any luck with docbook2pdf, xsltproc, xalan, fop, etc. You miss some options, probably also some basics. See next paragraph. I am amazed at how difficult the designers/architects have made this process. I can assure you, the developers did NOT try it to make it difficult just to annoy users. Actually it is really simple, you just need to understand some basic steps. Here are the steps from DocBook XML to PDF: 1. Validate your DocBook XML file first Do NOT skip this step! Use xmllint and run it like this: $ xmllint --xinclude --postvalid --noout book.xml If you encounter any problems, fix it. DO NOT processed further if you encounter any errors. The other steps rely on a valid DocBook source. 2. Transform your DocBook XML file into FO The FO file is an intermediate file which is read by your FO formatter. I've already wrote about how to run xsltproc. See lines above. 3. Format the FO file Now you take your FO file and feed it into the FO formatter: $ fop book.fo book.pdf These are three simple steps, each rely on the previous. If you have an invalid DocBook source, it is useless to go further. Just fix your file(s). The tranformation from DocBook to FO is usually without problems. When you try to format the intermediate FO file, that depends on the formatter. Sometimes FOP is a bit picky. :) Hope that helps. p, li { white-space: pre-wrap; } -- Gruß/Regards, Thomas Schraitle - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
Re: Default XSL Stylesheet for PDF?
On Tue, Oct 25, 2011 at 4:34 AM, flattr.toms...@online.ms wrote: Hi Jeffrey, p, li { white-space: pre-wrap; } On Tuesday 25 October 2011 Jeffrey Walton wrote: [...] If you were curious the -xml input is used in conjunction with an XSLT (thus the -xsl parameter) to transform said XML file to FO. There is no default PDF stylesheet, this mechanism is merely a helper since a lot of users create FO using a transform. OK. xalan also complains about a style sheet. These style sheets seem important. They are not important, they are essential! :-) OK. Dumb user question: if they are so important, why does the tool have no default style sheet to use? I would expect it to set margins at 1.00 inch (or 2 centimeters), etc. 1. Validate your DocBook XML file first Do NOT skip this step! Use xmllint and run it like this: $ xmllint --xinclude --postvalid --noout book.xml If you encounter any problems, fix it. DO NOT processed further if you encounter any errors. The other steps rely on a valid DocBook source. 2. Transform your DocBook XML file into FO The FO file is an intermediate file which is read by your FO formatter. I've already wrote about how to run xsltproc. See lines above. OK, thanks. I was not aware this was a multi-step process. 3. Format the FO file Now you take your FO file and feed it into the FO formatter: $ fop book.fo book.pdf OK. See below :( $ xmllint --xinclude --postvalid --noout book.xml # No complaints $ xsltproc --xinclude http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl book.xml book.fo # No complaints $ fop -fo book.fo -pdf book.pdf # All hell breaks loose Thanks for the help. It is greatly appreciated. Jeff Oct 25, 2011 5:07:37 AM org.apache.fop.cli.Main startFOP SEVERE: Exception org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: html) instead. Please make sure you're producing a valid XSL-FO document. javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: html) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:217) at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:125) at org.apache.fop.cli.Main.startFOP(Main.java:166) at org.apache.fop.cli.Main.main(Main.java:197) Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: html) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:502) at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:214) ... 3 more Caused by: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: html) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:262) at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:163) at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1073) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 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.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485) ... 4 more - javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: html) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:502)
Re: Default XSL Stylesheet for PDF?
On Tue, Oct 25, 2011 at 4:31 AM, Eduard Tibet eduard.ti...@i-free.com wrote: Jeff, Despite your question is more about Docbook specific points, than FOP, I'll try to give you an idea. My bad. When the other tools did not work, someone (on a mailing list) suggested I use Apache FOP. If you are using Docbook, try the following 2-step transformation. 1. Use xsltproc to create a FO file using default Docbook: xsltproc --xinclude --output book.fo path_to_your_docbook_xsl_stylesheets/docbook-xsl-1.76.1/fo/docbook.xsl book.xml As a result you will get .fo-file: book.fo 2. Using FOP try to create PDF: fop book.fo book.pdf Hope this helps. P.S. If you are using Windows OS, replace the slash to the opposite one (sorry, but I forgot about what slash is reverse and what is normal). Thanks for the help, jeff - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
Re: Default XSL Stylesheet for PDF?
Hi Jeffrey, On Tuesday 25 October 2011 Jeffrey Walton wrote: [...] OK. Dumb user question: if they are so important, why does the tool have no default style sheet to use? There are no default style sheets. It is the user who has to set these. The important thing is, you just need to give them as an option to your respective XML program. I would expect it to set margins at 1.00 inch (or 2 centimeters), etc. That's a different thing and has nothing to do with default style sheets. :) This is a layout issue. Of course, you can set this things in the stylesheets. [...] OK, thanks. I was not aware this was a multi-step process. Yes, it is. :-) 3. Format the FO file Now you take your FO file and feed it into the FO formatter: $ fop book.fo book.pdf OK. See below :( $ xmllint --xinclude --postvalid --noout book.xml # No complaints $ xsltproc --xinclude http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl [...] NO! :-) You need fo, _not_ html! The URL is wrong: just replace the /html/ part with /fo/. The xsltproc processor indeed does not complain, because it was a correct transformation, although in HTML. But HTML is not the correct input format for your FO formatter. :-) Tom - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
RE: Default XSL Stylesheet for PDF?
why does the tool have no default style sheet to use? I would expect it to set margins at 1.00 inch (or 2 centimeters), etc. FOP (*) is passed a single file to process. This known as XSL-FO. (or often just FO) It contains all such measurements. The stylesheet is applied during the preparation of the FO file. This is not (**) done by FOP but by another processor, eg xsltproc, Saxon, Xalan. Such programs do also take a stylesheet as parameter, and combine the stylesheet data with the source data (eg DocBook). The output is XSL-FO (or html, or various other possibilities). The stylesheet that is used to produce the XSL-FO contains the default margins etc that you refer to. It writes these into the FO. Hope that help, Richard. (*) Or any other FO processor (ie XSL-FO to PDF convertor). (**) Actually I think FOP can be requested to do this process too, but is not usually used in that way. - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
Re: Default XSL Stylesheet for PDF?
On 10/25/11 5:09 AM, Jeffrey Walton wrote: On Tue, Oct 25, 2011 at 4:34 AM,flattr.toms...@online.ms wrote: Hi Jeffrey, p, li { white-space: pre-wrap; } On Tuesday 25 October 2011 Jeffrey Walton wrote: [...] If you were curious the -xml input is used in conjunction with an XSLT (thus the -xsl parameter) to transform said XML file to FO. There is no default PDF stylesheet, this mechanism is merely a helper since a lot of users create FO using a transform. OK. xalan also complains about a style sheet. These style sheets seem important. They are not important, they are essential! :-) OK. Dumb user question: if they are so important, why does the tool have no default style sheet to use? I would expect it to set margins at 1.00 inch (or 2 centimeters), etc. 1. Validate your DocBook XML file first Do NOT skip this step! Use xmllint and run it like this: $ xmllint --xinclude --postvalid --noout book.xml If you encounter any problems, fix it. DO NOT processed further if you encounter any errors. The other steps rely on a valid DocBook source. 2. Transform your DocBook XML file into FO The FO file is an intermediate file which is read by your FO formatter. I've already wrote about how to run xsltproc. See lines above. OK, thanks. I was not aware this was a multi-step process. 3. Format the FO file Now you take your FO file and feed it into the FO formatter: $ fop book.fo book.pdf OK. See below :( $ xmllint --xinclude --postvalid --noout book.xml # No complaints $ xsltproc --xinclude http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl book.xml book.fo # No complaints Jeffrey, You are using the wrong stylesheets. You have converted your book.xml to an HTML document. If you renamed book.fo to book.html and then opened it in firefox, you see it formatted properly. However, you need a FO document. Try: $ xsltproc --xinclude http://docbook.sourceforge.net/release/xsl/current/fo/fo.xsl book.xml book.fo Instead. It would probably be better to download the stylesheets to your hard drive, since it will take less time to process. Let me know if you still have problems. Paul $ fop -fo book.fo -pdf book.pdf # All hell breaks loose Thanks for the help. It is greatly appreciated. Jeff Oct 25, 2011 5:07:37 AM org.apache.fop.cli.Main startFOP SEVERE: Exception org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: html) instead. Please make sure you're producing a valid XSL-FO document. javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: html) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:217) at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:125) at org.apache.fop.cli.Main.startFOP(Main.java:166) at org.apache.fop.cli.Main.main(Main.java:197) Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: html) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:502) at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:214) ... 3 more Caused by: org.apache.fop.fo.ValidationException: Error: First element must be the fo:root formatting object. Found (Namespace URI: , Local Name: html) instead. Please make sure you're producing a valid XSL-FO document. at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:262) at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:163) at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1073) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 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
Re: Default XSL Stylesheet for PDF?
On 10/25/11 5:09 AM, Jeffrey Walton wrote: On Tue, Oct 25, 2011 at 4:34 AM,flattr.toms...@online.ms wrote: Hi Jeffrey, p, li { white-space: pre-wrap; } On Tuesday 25 October 2011 Jeffrey Walton wrote: [...] If you were curious the -xml input is used in conjunction with an XSLT (thus the -xsl parameter) to transform said XML file to FO. There is no default PDF stylesheet, this mechanism is merely a helper since a lot of users create FO using a transform. OK. xalan also complains about a style sheet. These style sheets seem important. They are not important, they are essential! :-) OK. Dumb user question: if they are so important, why does the tool have no default style sheet to use? I would expect it to set margins at 1.00 inch (or 2 centimeters), etc. 1. Validate your DocBook XML file first Do NOT skip this step! Use xmllint and run it like this: $ xmllint --xinclude --postvalid --noout book.xml If you encounter any problems, fix it. DO NOT processed further if you encounter any errors. The other steps rely on a valid DocBook source. 2. Transform your DocBook XML file into FO The FO file is an intermediate file which is read by your FO formatter. I've already wrote about how to run xsltproc. See lines above. OK, thanks. I was not aware this was a multi-step process. 3. Format the FO file Now you take your FO file and feed it into the FO formatter: $ fop book.fo book.pdf OK. See below :( $ xmllint --xinclude --postvalid --noout book.xml # No complaints $ xsltproc --xinclude http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl book.xml book.fo # No complaints $ fop -fo book.fo -pdf book.pdf # All hell breaks loose Thanks for the help. It is greatly appreciated. Woops. That stylesheet is not the main processing one. Try xsltproc --xincludestyle http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl book.xml book.fo Paul - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org