Page 1 of 1
DocBook to Epub cover tweaks
Posted: Tue Jul 26, 2011 8:15 pm
by jbzech
I'm loving the DocBook to Epub transform, and I have figured out how to get most of my customizations in there.
2 minor issues are plaguing me:
1) Is there a way to change or customize the filename generated for the cover image (JPEG for me) in the "images" folder? It appears that the filename is currently based on the directory location of the image being copied in, so I have an enormously long filename that shows my directory in my epub. I would be fine with a standard, generic filename, like "coverImage" or something. Where can I customize this output?
2) In the "content.opf" there is an <item id="cover-image"...> that I have to delete to get valid ePub. The HREF for this item is picked up from the fileref for the image in my XML (so it is no longer a valid href) and the media-type is empty. Both of these issues invalidate the ePub. I also can't figure out why I need this in my opf, since the cover.html is there as well as a listing for the cover image itself in the images folder. Is this <item> necessary in my opf? How can I stop the transformation from producing it?
Thanks!
Re: DocBook to Epub cover tweaks
Posted: Wed Jul 27, 2011 12:20 pm
by sorin_ristache
Hello,
jbzech wrote:1) Is there a way to change or customize the filename generated for the cover image (JPEG for me) in the "images" folder? It appears that the filename is currently based on the directory location of the image being copied in, so I have an enormously long filename that shows my directory in my epub. I would be fine with a standard, generic filename, like "coverImage" or something. Where can I customize this output?
Oxygen modifies the image file names from the
item elements of
content.opf with an image type
media-type. The
item element with the path of the cover image file is not modified because it does not have a
media-type attribute. We will have to correct also in a future version of Oxygen the path of the image file in this
item element. If you want to try it yourself you could modify the body of the
xsl:if element from line 1038 of the stylesheet
[OXYGEN-INSTALL-DIR]/frameworks/docbook/xsl/epub/docbook.xsl and generate also a
media-type attribute in that
item element. It starts with:
Code: Select all
<xsl:if test="generate-id(.) = generate-id(key('image-filerefs', $fr)[1])">
jbzech wrote:2) In the "content.opf" there is an <item id="cover-image"...> that I have to delete to get valid ePub. The HREF for this item is picked up from the fileref for the image in my XML (so it is no longer a valid href) and the media-type is empty. Both of these issues invalidate the ePub. I also can't figure out why I need this in my opf, since the cover.html is there as well as a listing for the cover image itself in the images folder. Is this <item> necessary in my opf? How can I stop the transformation from producing it?
As an alternative for the above suggestion you could try to remove the
<item id="cover-image"...> element from
content.opf by adding the following template to the stylesheet
[OXYGEN-INSTALL-DIR]/frameworks/docbook/xsl/epub/removeImagesContentOpf.xsl:
Code: Select all
<xsl:template match="opf:item[@id = 'cover-image']"/>
Regards,
Sorin
Re: DocBook to Epub cover tweaks
Posted: Wed Jul 27, 2011 9:56 pm
by jbzech
I was able to get the template in that removes "cover-image" successfully. Changing the xsl:if that handles filenaming might be beyond my current XSLT skills. I'll keep poking at it.
Thank you for the help.
Re: DocBook to Epub cover tweaks
Posted: Wed Jul 27, 2011 9:58 pm
by jbzech
Can you point me toward where I might find the template "mediaobject.filename"? Seems like that might be part of it, but I'm not sure where this template is called from.
Re: DocBook to Epub cover tweaks
Posted: Thu Jul 28, 2011 12:10 am
by jbzech
Nevermind. Found it in common.xsl. Not the place I need to go.
Re: DocBook to Epub cover tweaks
Posted: Thu Jul 28, 2011 3:35 pm
by sorin_ristache
To find where the mediaobject.filename template is called from you can run the transformation in the Oxygen XSLT debugger, place a breakpoint inside the mediaobject.filename template, run the transformation to the breakpoint and at that moment look in the Stack view to see the caller template.
Regards,
Sorin
Re: DocBook to Epub cover tweaks
Posted: Wed Sep 28, 2011 5:33 pm
by adrian
Hello,
I just wanted to let you know that we have corrected the path of the cover image file in the latest build of Oxygen 13.0, 2011091610:
The fix was made in "Oxygen/frameworks/docbook/xsl/epub/addImagesContentOpf.xsl"
DocBook to EPUB: Fixed some problems from the EPUB published by the Docbook to EPUB transformation.
The complete list of bug-fixes for this build can be found here:
http://www.oxygenxml.com/build_history.html#2011091610
You can download it from our web site:
http://www.oxygenxml.com/download.html
Note that if you upgrade your current installation of Oxygen, you will lose any modifications/customizations you have made to the files from the Oxygen directory.
Regards,
Adrian