Commit fc427b0c authored by cliclac's avatar cliclac

Mise en place des chapitres et de l'epub

parent 05887f58
......@@ -35,15 +35,23 @@ La personne possède un hdoc et voudrait le convertir en epub. Il se dirige vers
Unsupported
-----------
Known bugs
----------
Problème dans le hdoc : contient des images mais ne sont pas référencées.
Problème avec les keywords : le hdoc contient des keywords mais nous ne savons pas où les utiliser.
Todo list
---------
Validation de l'epub actuel
Mise en place de la première page
Validation
Étude compatibilité entre EPUB2 et EPUB3
Technical Notes
---------------
<?xml version="1.0"?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
<rootfile full-path="oebps/content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
......@@ -11,6 +11,7 @@
<property name="file" location="${basedir}/file"/>
<property name="schema" location="${basedir}/schema"/>
<property name="lib" location="${basedir}/lib"/>
<property name="tmpRetour" location="${basedir}/tmp/retour"/>
<target name="convert">
<delete dir="${tmp}" failonerror="false"/>
......@@ -21,6 +22,8 @@
<sleep seconds="1"/>
<mkdir dir="${out}"/>
<mkdir dir="${tmpRetour}"/>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
......@@ -38,7 +41,9 @@
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="MakeOCF"/>
<antcall target="MakeOCF">
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="MakeOPF">
<param name="filename" value="${filename}"/>
......@@ -48,6 +53,15 @@
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="ZipEpubFile">
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="ValidateOutput">
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="CleanTmp"/>
</sequential>
</for>
</target>
......@@ -72,25 +86,49 @@
</target>
<target name="MakeOCF">
<mkdir dir="${out}/META-INF"/>
<mkdir dir="${out}/oebps"/>
<copy file="${file}/mimetype" todir="${out}"/>
<copy file="${file}/container.xml" todir="${out}/META-INF"/>
<mkdir dir="${tmpRetour}/META-INF"/>
<mkdir dir="${tmpRetour}/oebps"/>
<copy file="${file}/mimetype" todir="${tmpRetour}"/>
<copy file="${file}/container.xml" todir="${tmpRetour}/META-INF"/>
</target>
<target name="MakeOPF">
<xslt in="${tmp}/${filename}/decompressedHdoc/content.xml" out="${out}/oebps/content.xml" classpath="${lib}/saxon9he.jar" style="${xsl}/content.xsl"/>
<xslt in="${tmp}/${filename}/decompressedHdoc/content.xml" out="${tmpRetour}/oebps/content.opf" classpath="${lib}/saxon9he.jar" style="${xsl}/content.xsl"/>
</target>
<target name="MakeOPS">
<mkdir dir="${out}/oebps/images"/>
<copy todir="${out}/oebps/images">
<mkdir dir="${tmpRetour}/oebps/images"/>
<copy todir="${tmpRetour}/oebps/images">
<fileset dir="${tmp}/${filename}/decompressedHdoc/re" includes="**"/>
</copy>
<mkdir dir="${out}/oebps/styles"/>
<mkdir dir="${out}/oebps/chapitres"/>
<xslt in="${tmp}/${filename}/decompressedHdoc/content.xml" out="${out}/oebps/tableDesMatieres.ncx" classpath="${lib}/saxon9he.jar" style="${xsl}/tdmncx.xsl"/>
<mkdir dir="${tmpRetour}/oebps/styles"/>
<mkdir dir="${tmpRetour}/oebps/chapitres"/>
<xslt in="${tmp}/${filename}/decompressedHdoc/content.xml" out="${tmpRetour}/oebps/tableDesMatieres.ncx" classpath="${lib}/saxon9he.jar" style="${xsl}/tdmncx.xsl"/>
<xslt destdir="${tmpRetour}/oebps/chapitres" basedir="${tmp}/${filename}/decompressedHdoc" includes="content.xml" classpath="${lib}/saxon9he.jar" style="${xsl}/chapitre.xsl"/>
<delete file="${tmpRetour}/oebps/chapitres/content.html"/>
</target>
<target name="ZipEpubFile">
<propertyregex property="properFilename" input="${filename}" regexp=".hdoc" replace="" casesensitive="false" override="true" />
<zip destfile="${out}/${properFilename}.epub" update="true" encoding="UTF-8">
<zipfileset dir="${tmpRetour}/META-INF"
includes="*" prefix="META-INF"/>
<zipfileset dir="${tmpRetour}/oebps"
includes="**" prefix="oebps"/>
</zip>
<!-- zip64Mode="never" -->
<zip destfile="${out}/${properFilename}.epub" update="true" compress="false" encoding="UTF-8" keepcompression="true" createunicodeextrafields="never">
<zipfileset dir="${tmpRetour}"
includes="mimetype"/>
</zip>
</target>
<target name="ValidateOutput">
</target>
<target name="CleanTmp">
<delete dir="${tmp}" failonerror="false"/>
</target>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
version="2.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/html" priority="10">
<xsl:for-each select="body/section">
<xsl:variable name="path">../../../retour/oebps/chapitres/chapitre<xsl:number level="multiple" count="section" format="1"/>.xhtml</xsl:variable>
<xsl:result-document method="xml" href="{$path}">
<html xml:lang="en" lang="en" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title><xsl:value-of select="header/h1"/></title>
</head>
<body>
<h1><xsl:value-of select="header/h1"/></h1>
<xsl:apply-templates select="div|section"/>
</body>
</html>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
<xsl:template match="section" priority="3">
<xsl:element name="h{count(ancestor::section)+1}">
<xsl:value-of select="header/h1"/>
<xsl:apply-templates select="div|section"/>
</xsl:element>
</xsl:template>
<!-- Identity transformation -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- Namespace substitution for hdoc elements -->
<xsl:template match="*" priority="1">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
......@@ -3,12 +3,13 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
xmlns="http://www.daisy.org/z3986/2005/ncx/"
version="2.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="html">
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en-US">
<ncx version="2005-1" xml:lang="en-US">
<head>
<meta content="org-example-5059463624137734586" name="dtb:uid"/>
</head>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment