ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Henning Hraban Ramm <texml@fiee.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: E-books and XML.
Date: Wed, 27 Aug 2014 13:02:27 +0600	[thread overview]
Message-ID: <11FBFD1E-F926-4897-8ECE-ABA34F1B104A@fiee.net> (raw)
In-Reply-To: <53FCC415.2070001@wxs.nl>


Am 2014-08-26 um 23:29 schrieb Hans Hagen <pragma@wxs.nl>:

> On 8/26/2014 7:08 PM, Henning Hraban Ramm wrote:
> 
>> Creating ePub from ConTeXt is still tedious - you need to tag everything (even paragraphs) with \start/\stop, the resulting export.xml is still missing a root node if you use project structure (components), and you need to tinker a lot with the results, since even available information like title is not written to the relevant ePub files.
> 
> rootnode .. in what sense?

Sorry Hans, I complained about that several times already:

If I have a project structure, i.e. a product with components, export.xml starts like

“““
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<!-- input filename   : prd_hraban        -->
<!-- processing date  : Tue Aug 26 12:55:41 2014 -->
<!-- context version  : 2014.08.19 11:57  -->
<!-- exporter version : 0.31              -->

<division detail="frontpart">
 <metadata>
“““

And since there are several <division>s or other top nodes, Saxon rejects the file because it’s missing a root node.
<metadata> is always put into the first node of the file (that should be the root node).

Only with a single TeX file, I get something like

“““
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>

<!-- input filename   : solo              -->
<!-- processing date  : Wed Mar 12 11:06:58 2014 -->
<!-- context version  : 2014.03.07 11:42  -->
<!-- exporter version : 0.30              -->

 <document language="en" file="solo" date="Wed Mar 12 11:06:58 2014" context="2014.03.07 11:42" version="0.30" xmlns:m="http://www.w3.org/1998/Math/MathML">
 <metadata>
“““

I.e. the root node <document> is missing.


If you were to enhance ePub facilities (how much must I pay you?), it would be nice to see the data that you put in „metavariables“ (title, author) also in the generated OPF, NCX and cover files, and the main language in OPF.
My script also creates a cover image from the first page of the content PDF as well as converts and copies all the included images, but your usual reasoning that everyone has other needs is of course true.

I resolved to generate content, cover, NCX and OPF from export.xml via XSLT, i.e. throw away most of what the epub script does.
But the structure of registers (that I abuse for a sorted ToC) is hard to parse, because there’s no structure that links register text and page number, e.g.:

   <register detail="index">
    <registersection><!-- probably „A“ -->
     <registerentries>
      <registerentry>A Elbereth Gilthoniel</registerentry>
      <registerpages>        <break/>
<registerpage><link destination="internal(105)" location="aut:105">47</link></registerpage></registerpages>
      <registerentry>Abitur</registerentry>
      <registerpages>        <break/>
<registerpage><link destination="internal(87)" location="aut:87">38</link></registerpage></registerpages>
      <registerentry>Agradini</registerentry>
      <registerpages>        <break/>
<registerpage><link destination="internal(32)" location="aut:32">16</link></registerpage></registerpages>
      <registerentry>Amselchen</registerentry>
      <registerpages>        <break/>
<registerpage><link destination="internal(136)" location="aut:136">66</link></registerpage></registerpages>

My XSL for NCX looks like:

<?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" >
        	<xsl:attribute name="content">
        	<xsl:value-of select='count(section[@detail="Titel"])' />
        	</xsl:attribute>
        </meta>
        <meta name="dtb:maxPageNumber">
        	<xsl:attribute name="content">
        	<xsl:value-of select='count(section[@detail="Titel"])' />
        	</xsl:attribute>
        </meta>
    </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>



Greetlings, Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2014-08-27  7:02 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-26 15:07 john Culleton
2014-08-26 15:10 ` Wolfgang Schuster
2014-08-26 17:08   ` Henning Hraban Ramm
2014-08-26 17:29     ` Hans Hagen
2014-08-27  7:02       ` Henning Hraban Ramm [this message]
2014-08-27  9:05         ` Hans Hagen
2014-08-27  9:25           ` Henning Hraban Ramm
2014-08-27  9:37             ` Hans Hagen
2014-08-27  9:46               ` Henning Hraban Ramm
2014-08-27 10:06                 ` Hans Hagen
2014-08-28  8:10                   ` Henning Hraban Ramm
2014-08-28  8:22                     ` Hans Hagen
2014-08-28 10:54                       ` Henning Hraban Ramm
2014-08-28 13:34                         ` Hans Hagen
2014-08-28 13:35                         ` Hans Hagen
2014-08-28 17:39                         ` Hans Hagen
2014-08-29  6:33                           ` Henning Hraban Ramm
2014-08-29 10:17                             ` Hans Hagen
2014-08-29 11:46                               ` Henning Hraban Ramm
2014-08-29 12:46                                 ` Hans Hagen
2014-08-30  7:56                                   ` Henning Hraban Ramm
     [not found]                                 ` <540AEA44.2080106@wxs.nl>
     [not found]                                   ` <540C26D3.1020101@wxs.nl>
2014-09-13  7:29                                     ` Henning Hraban Ramm
2014-08-27  9:03     ` Henning Hraban Ramm
2014-08-26 18:04 ` Hans Hagen
2014-08-26 18:12   ` Thomas A. Schmitz
2014-08-27 14:03     ` XML as source (was: E-books and XML) Procházka Lukáš Ing. - Pontex s. r. o.
2014-08-27 18:40       ` Jan Tosovsky
2014-08-28 17:02       ` Mica Semrick
2014-08-27 14:38     ` E-books and XML john Culleton
2014-08-27 16:15       ` Schmitz Thomas A.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11FBFD1E-F926-4897-8ECE-ABA34F1B104A@fiee.net \
    --to=texml@fiee.net \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).