Try this instead:
mystyles.xsl:
[ only import fo/docbook.xsl ]
<?xml version="1.0"?> <xsl:stylesheet version='1.0'
xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"
xmlns:fo=" http://www.w3.org/1999/XSL/Format"> <xsl:import
href="/opt/docbook-xsl-1.71.1/fo/docbook.xsl"/> <xsl:template
name="book.titlepage.recto"> <fo:block>​
<fo:external-graphic src="url(images/logo.png)"/>
</fo:block> </xsl:template> </xsl:stylesheet>
[ only process with mystyles.xsl, and set
fop.extensions to 1]
$XSLTPROC
\ --stringparam page.margin.inner 0.75in \ --stringparam
page.margin.outer 0.5in \ --stringparam title.margin.left 0.5in
\ --stringparam admon.graphics 1 \ --stringparam
admon.graphics.path "images/" \ --stringparam
admon.graphics.extension ".png" \ --stringparam header.rule 1
\ --stringparam footer.rule 1 \ --stringparam
section.autolabel 1 \ --stringparam
section.label.includes.component.label 1 \ --stringparam title.font.family
"Times Roman" \ --stringparam body.font.family "Helvetica" \ --stringparam
dingbat.font.family "Courier" \ --stringparam draft.mode "yes"
\ --stringparam draft.watermark.image "./images/draft.png"
\ --stringparam fop.extensions 1 \ mystyles.xsl test.xml >
test.fo
You could also move most of those parameters into
mystyles.xsl as:
<xsl:param
name="fop.extensions">1</xsl:param>
----- Original Message -----
Sent: Thursday, January 25, 2007 9:56
PM
Subject: Re: [docbook-apps] docbook 5
cover page example
Thanks for the explaination. My xsltproc looks
like,
$XSLTPROC \ --stringparam page.margin.inner 0.75in
\ --stringparam page.margin.outer 0.5in \ --stringparam
title.margin.left 0.5in \ --stringparam admon.graphics 1
\ --stringparam admon.graphics.path "images/"
\ --stringparam admon.graphics.extension ".png"
\ --stringparam header.rule 1 \ --stringparam footer.rule 1
\ --stringparam section.autolabel 1 \ --stringparam
section.label.includes.component.label 1 \ --stringparam title.font.family
"Times Roman" \ --stringparam body.font.family "Helvetica"
\ --stringparam dingbat.font.family "Courier" \ --stringparam
draft.mode "yes" \ --stringparam draft.watermark.image
"./images/draft.png" \ --stringparam shade.verbatim 1
\ /opt/docbook-xsl-1.71.1/fo/docbook.xsl mystyles.xsl test.xml > test.fo
fop.sh test.fo -pdf test.pdf
and I get
......
ERROR: Document root element for FO output must be one of the
following elements: appendix article bibliography book chapter colophon
dedication glossary index part preface qandaset refentry reference sect1
section set setindex Making portrait pages on USletter paper
(8.5inx11in) [INFO] Using org.apache.xerces.parsers.SAXParser as SAX2
Parser [INFO] FOP 0.20.5 [INFO] Using
org.apache.xerces.parsers.SAXParser as SAX2 Parser [INFO] building
formatting object tree
mystyles.xsl is, <?xml
version="1.0"?> <xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo=" http://www.w3.org/1999/XSL/Format"> <xsl:import
href="/opt/docbook-xsl-1.71.1/fo/docbook.xsl"/> <xsl:include
href="/opt/docbook-xsl-1.71.1 /fo/custom.xsl"/> <xsl:import
href="/opt/docbook-xsl-1.71.1/fo/custom.xml"/>
<xsl:template
name="book.titlepage.recto"> <fo:block>​
<fo:external-graphic src="url(images/logo.png)"/>
</fo:block> </xsl:template> </xsl:stylesheet>
I
get the PDF. Still nothing on titlepage *sigh*
Josh
On 1/25/07, Bob Stayton
<bobs@sagehill.net>
wrote:
Hi,
Ah, there is a bit of a misunderstanding here.
Your book.titlepage.recto template is outputting an unprocessed
<mediaobject> element to your FO file instead of what it gets
processed into, which is a <fo:external-graphic> element.
Your XSL-FO processor doesn't know how to handle that <mediaobject>
element.
The titlepage spec mechanism is kind of
complicated, but that's because everyone wants their titlepage to be
different. There are many potential elements in bookinfo that could be
on the title pages, in many orders, and in many different formats. The
titlepage spec file lets you specify those things without having to write
full XSL-FO code to format them. It is a code generator. But
there are times when you don't need all that complexity, and you can bypass
it and write your own XSL-FO code instead.
My suggestion of editing a copy of
titlepage.templates.xml was to add a mediaobject element to the titlepage
specs. But that is for handling a mediaobject inside the bookinfo
element so you can have a different image for each document, specified in
the document itself.
In your case, it looks like
what you want is a constant logo, which would be output in all documents, so
you wouldn't want or need to specify the logo filename in each
document. If that is the case, you can skip the titlepage
specification step and simply edit the template with
name="book.titlepage.recto", as in your first attempt. You just need
to provide the correct XSL-FO syntax instead of DocBook elements:
<!-- I usually use a parameter rather than
hard code things like logo filenames -->
<xsl:param
name="logo.filename">images/logo.jpg</xsl:param>
<!-- Then reference the parameter in the
XSL-FO syntax for an image. It should be inside an fo:block in
case you need to add othe properties. -->
<xsl:template
name="book.titlepage.recto">
<fo:block> <fo:external-graphic
src="url($logo.filename)"
width="100%" content-width="scale-to-fit"/>
</fo:block> </xsl:template>
This will output the logo image full
width onto the front page, and nothing else. If you want a title or such,
then take a look at the template with that name in
fo/titlepage.templates.xsl to see how it handles the other elements like
titles, and add them to your custom template.
-----
Original Message -----
Sent:
Thursday, January 25, 2007 6:09 PM
Subject:
Re: [docbook-apps] docbook 5 cover page example
Thanks for the information. I was hoping for a much easier
way of adding an image to the title page. Here's what I have been doing
unsuccessfully,
1. Copy docbook-xsl/fo/title.template.page.xml as
custom.xml 2. Edit custom.xml and add <mediaobject/> to
<bookinfo> 3. Generate custom.xsl from custom.xml using
xsltproc 4. Create a mycustom.xsl that includes custom.xml and
custom.xsl with <mediaobject/>. For example,
<!-- BEGIN
XSL --> <?xml version="1.0"?> <xsl:stylesheet
version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform " xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:import
href="/opt/docbook-xsl-1.71.1/fo/docbook.xsl"/> <xsl:include
href="/opt/docbook- xsl-1.71.1/fo/custom.xsl"/> <xsl:import
href="/opt/docbook-xsl-1.71.1/fo/custom.xml"/>
<xsl:template
name="book.titlepage.recto"> <mediaobject>
<imageobject>
<imagedata fileref="images/logo.jpg" format="JPEG"
/>
</imageobject> </mediaobject> </xsl:template> </xsl:stylesheet> <!
-- END XSL -->
5. I get an error when I compile, but
xsltproc processes my XML files and so does FOP. I have the PDF without
the title image. I don't recall the error completely other than the root
element should be one of article..... something like that. I can try it
and get the exact error if it helps.
Any help would be
appreciated.
Thanks
On 1/25/07, Bob Stayton <bobs@sagehill.net >
wrote:
Hi,
Unfortunately, cover is not currently
implemented in the stylesheets. The cover element was added to
allow a document to specify the information to appear on a cover. In
practice, a cover is not usually generated with the document output
because it has to be in a separate output file for production
purposes.
I think what you want is to add an image to
your titlepage. That can be done using the titlepage spec file
mechanism, as described in this section:
The section titled "Titlepage spec file" on
that HTML page describes how to process the spec file after you have
customized it. Then any mediaobject inside your bookinfo or info
element will be output on the titlepage.
-----
Original Message -----
Sent:
Thursday, January 25, 2007 12:32 PM
Subject:
[docbook-apps] docbook 5 cover page example
Hello,
I'm trying to get an image on the index
page and my attempts have been unsuccessful. I have read numerous
posts (including sagehill books) about customizing it with XSL
templates and all. It is quite confusing and complicated for a docbook
newbie and my attempts have failed.
I moved to docbook 5 (and
docbook5-xsl-1.72.0) to use the cover page feature which makes it
easier to add the image on the first page.
To begin with, I
coped and saved the example from the following link to add a JPG logo
to the first page, http://www.docbook.org/tdg5/en/html/cover.html
The
book compiles fine using xsltproc with FOP 0.93, but I don't see an
image. but everything else is available.
I'm lost and does
anyone have any experience or ideas to get this done?
Thanks in
advance!
|