OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] adding a cover image to the PDF


Sorry, I answered too quickly and didn't check my work.

I'll offer my explanation of how this should work.  In FO output, all content needs to 
be inside a fo:page-sequence, and fo:page-sequences do not nest.  In the template that 
matches on "book" in fo/division.xsl, several fo:page-sequences may be created.  The 
first one would be for the front.cover, if that template is not empty.  The second 
fo:page-sequence is for the titlepages, created by the call to "book.titlepage". 
These are followed by separate page-sequences for dedication, acknowledgements, and 
TOCs (if they are included).  Then the book's content is processed, which generates a 
separate page-sequence for each chapter and other component.  Then a final 
page-sequence may be generated by the "back.cover" template, if that template is not 
empty.

So the front.cover page-sequence is independent of the titlepage page-sequence.  It 
needs to have all the components of a fo:page-sequence, which is why the utility 
template named "page.sequence" was created.  It handles all the details, you just have 
to provide the variable information through the template parameters.  That variable 
information includes a) the content and b) setting which fo:page-sequence-master 
should be used (which determines margins and such for a given page-sequence).  The 
master-reference parameter in my suggestion selects "titlepage" from among the set of 
fo:page-master-sequences defined in fo/pagesetup.xsl.

The front.cover page-sequence also needs to have valid FO content, and that's where I 
goofed.  I put a DocBook mediaobject in there, and that is most decidedly not a valid 
FO element.  Instead of <mediaobject> I should have put the FO elements that would 
have been generated by the stylesheet when a DocBook mediaobject is processed.  Duh.

So here is a better example:

<xsl:template name="front.cover">
  <xsl:call-template name="page.sequence">
    <xsl:with-param name="master-reference">titlepage</xsl:with-param>
    <xsl:with-param name="content">
      <fo:block text-align="center" [add any other block properties here]>
        <fo:external-graphic src="url(fo-images/criteria-tag312.jpg)" 
content-width="7cm" [add any other image properties here]/>
      </fo:block>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>


Bob Stayton
Sagehill Enterprises
bobs@sagehill.net


----- Original Message ----- 
From: "Robert Nagle" <idiotprogrammer@gmail.com>
To: "Bob Stayton" <bobs@sagehill.net>
Cc: <docbook-apps@lists.oasis-open.org>
Sent: Wednesday, August 25, 2010 10:39 AM
Subject: Re: [docbook-apps] adding a cover image to the PDF


That didn't work with a strange fo message.

net.sf.saxon.trans.XPathException:
org.apache.fop.fo.ValidationException: "fo:flow" is missing child
elements. Required content model: marker* (%block;)+ (See position
1:-1)

Looking at the example on 13.12,  I'm guessing that you are assuming
that I have already created a titlepage template and added it to my
customization file.  I have not done this (although I plan to).
http://www.sagehill.net/docbookxsl/PageDesign.html#CustomPageSequences

If that is not the case, I'm afraid I really have no idea what the
following line means:

<xsl:with-param name="master-reference">titlepage</xsl:with-param>

Rather than ask you (or someone else) to explain, let me offer my
(probably wrong) guess about what the code you provided does, and you
can tell me how  wrong I am. Are you ready to laugh?!

********************************PROBABLY WRONG!
Docbook lets you add a statement to your customization layer file  to
invoke a blank template called front.cover. In this front.cover
template, you can add extra information which will alter the titlepage
template and in this case, specifically a component of titlepage
called page.sequence. This page.sequence subtemplate will alter the
xsl-fo output from the entire docbook project  so that any  raw
docbook xml appearing inside the <xsl:with-param name="content"> will
slip neatly inside the titlepage template.


********************************END OF PROBABLY WRONG!

Have I told you I am good at writing fiction? :)

Robertr






On Wed, Aug 25, 2010 at 11:39 AM, Bob Stayton <bobs@sagehill.net> wrote:
> Hi Robert,
> The existing template that matches on book in fo/division.xsl already calls
> the template named "front.cover", so you don't need that bit. For the other
> template, I think all you need to add is putting the content into a
> page-sequence, which can be done with the utility template named
> "page.sequence" created for that purpose. An example of its usage is here:
>
> http://www.sagehill.net/docbookxsl/PageDesign.html#CustomPageSequences
>
> In your case, it might look like this:
>
> <xsl:template name="front.cover">
> <xsl:call-template name="page.sequence">
> <xsl:with-param name="master-reference">titlepage</xsl:with-param>
> <xsl:with-param name="content">
> <mediaobject ...
> </xsl:with-param>
> </xsl:call-template>
> </xsl:template>
>
> Bob Stayton
> Sagehill Enterprises
> bobs@sagehill.net
>
>
> ----- Original Message ----- From: "Robert Nagle"
> <idiotprogrammer@gmail.com>
> To: <docbook-apps@lists.oasis-open.org>
> Sent: Wednesday, August 25, 2010 8:13 AM
> Subject: [docbook-apps] adding a cover image to the PDF
>
>
>> Hi, there I need to produce a pre-release of my print book as a PDF.
>> It's due tomorrow. It won't be "totally ready" (and I have not added
>> a title page), but I just wanted to include a jpg for the page that
>> will be the front cover.
>>
>> I'm using Apache FOP, although eventually I'll be using XEP.
>>
>> This seems hard.
>>
>> Reading through the docs and the mailing list, I tried to do this in
>> my xslt file:
>>
>> *****************************************
>> <xsl:template name="front.cover">
>> <mediaobject>
>>
>> <imageobject role="fo">
>> <imagedata fileref="fo-images/criteria-tag312.jpg"
>> contentwidth="7cm"/>
>> </imageobject>
>> </mediaobject>
>>
>> </xsl:template>
>>
>> <xsl:template match="book">
>> <xsl:call-template name="front.cover"/>
>> <xsl:apply-imports/>
>> </xsl:template>
>>
>> *****************************************************************************
>> I'm sure I'm missing some subtlety here, but shouldn't be easy as this?
>>
>> One other thought is that perhaps front.cover needs to be in fo, but
>> frankly I have no idea how to go about that.
>>
>> This is stuff I need to learn pretty soon anyway, but for tomorrow is
>> there a simple and dirty solution to this?
>>
>> in my index.xml I have this at the top:
>>
>> <info>
>> <title>My Book Title </title>
>> <author>
>> <personname>
>> <firstname>Robert </firstname>
>> <surname>Nagle </surname>
>> </personname>
>> </author>
>> <!--<cover>
>> <mediaobject>
>>
>> <imageobject role="fo">
>> <imagedata fileref="fo-images/criteria-tag312.jpg"
>> contentwidth="7cm"/>
>> </imageobject>
>> </mediaobject>
>> </cover>-->
>> ***************************** I tried referencing it here also without
>> success
>> </info>
>>
>>
>>
>> --
>> Robert Nagle
>> 12777 Ashford Point Dr #1417
>> Houston, Texas 77082
>> 713 893 3424
>> htpt://www.robertnagle.info
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
>> For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
>>
>>
>>
>
>



-- 
Robert Nagle
12777 Ashford Point Dr #1417
Houston, Texas 77082
713 893 3424
htpt://www.robertnagle.info

---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org





[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]