Changes

Jump to navigation Jump to search
3,575 bytes added ,  08:39, 27 August 2014
create OPF & NCX
</xmlcode>
If you don’t have a different cover picture, create one from the first page of your PDF (using ImageMagick’s {{code|convert}}):
<pre>
convert -density 196 somgbooksongbook.pdf'[0]' +repage cover.jpg
</pre>
 
== Create OPF ==
 
This file keeps the others together.
 
<xmlcode>
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version= "2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
<xsl:output
method="xml"
encoding="utf-8"
indent="yes"
/>
 
<xsl:template match="/">
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
 
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
<dc:title><xsl:value-of select='//metavariable[@name="title"]'/></dc:title>
<dc:language><xsl:value-of select='//document/@language'/></dc:language>
<dc:identifier id="BookId" opf:scheme="UUID">urn:uuid:xxxx</dc:identifier>
<dc:creator><xsl:value-of select='//metavariable[@name="author"]'/></dc:creator>
<dc:date><xsl:value-of select='//document/@date'/></dc:date>
<meta name="cover" content="-" />
</metadata>
 
<manifest>
<item id="cover-xhtml" href="cover.xhtml" media-type="application/xhtml+xml"/>
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
<item id="content-xhtml" href="content.xhtml" media-type="application/xhtml+xml"/>
</manifest>
 
<spine toc="ncx">
<itemref idref="cover-xhtml" />
<itemref idref="content-xhtml" />
</spine>
 
</package>
</xsl:template>
 
</xsl:stylesheet>
</xmlcode>
 
== Create NCX (table of contents) ==
 
This one will probably differ from your setup – I (ab)use an index for an alphabetically ordered table of contents.
The structure that ConTeXt outputs for index entries is somewhat uncomfortable...
 
<xmlcode>
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version= "2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
<xsl:output
method="xml"
encoding="utf-8"
indent="yes"
/>
 
<xsl:template match="/">
<!--
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
-->
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
 
<head>
<meta name="dtb:uid" content="BookId" />
<meta name="dtb:depth" content="1" />
<meta name="dtb:totalPgeCount" content="0" />
<meta name="dtb:maxPageNumber" content="0" />
</head>
 
<docTitle>
<text><xsl:value-of select='//metavariable[@name="title"]'/></text>
</docTitle>
 
<docAuthor>
<text><xsl:value-of select='//metavariable[@name="author"]'/></text>
</docAuthor>
 
<navMap>
<navPoint id="aut_1" playOrder="1">
<navLabel>
<text>Start</text>
</navLabel>
<content src="content.xhtml"/>
</navPoint>
<xsl:for-each select="//registerentry">
<navPoint>
<xsl:attribute name="id">
<xsl:value-of select='translate((following-sibling::registerpages/registerpage/link/@location)[1], ":", "_")'/>
</xsl:attribute>
<xsl:attribute name="playOrder">
<xsl:value-of select="2 + count(preceding-sibling::registerentry)" />
</xsl:attribute>
<navLabel>
<text><xsl:apply-templates/></text>
</navLabel>
<content>
<xsl:attribute name="src">content.xhtml#<xsl:value-of select='translate((following-sibling::registerpages/registerpage/link/@location)[1], ":", "_")'/></xsl:attribute>
</content>
</navPoint>
</xsl:for-each>
 
</navMap>
</ncx>
</xsl:template>
 
</xsl:stylesheet>
 
</xmlcode>
 
The links to a named anchor should work, but don’t in my reader. I must investigate further...

Navigation menu