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 ...@@ -35,15 +35,23 @@ La personne possède un hdoc et voudrait le convertir en epub. Il se dirige vers
Unsupported Unsupported
----------- -----------
Known bugs 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 Todo list
--------- ---------
Validation de l'epub actuel
Mise en place de la première page
Validation
Étude compatibilité entre EPUB2 et EPUB3
Technical Notes Technical Notes
--------------- ---------------
<?xml version="1.0"?> <?xml version="1.0"?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0"> <container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
<rootfiles> <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> </rootfiles>
</container> </container>
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
<property name="file" location="${basedir}/file"/> <property name="file" location="${basedir}/file"/>
<property name="schema" location="${basedir}/schema"/> <property name="schema" location="${basedir}/schema"/>
<property name="lib" location="${basedir}/lib"/> <property name="lib" location="${basedir}/lib"/>
<property name="tmpRetour" location="${basedir}/tmp/retour"/>
<target name="convert"> <target name="convert">
<delete dir="${tmp}" failonerror="false"/> <delete dir="${tmp}" failonerror="false"/>
<sleep seconds="1"/> <sleep seconds="1"/>
...@@ -20,6 +21,8 @@ ...@@ -20,6 +21,8 @@
<delete dir="${out}" failonerror="false"/> <delete dir="${out}" failonerror="false"/>
<sleep seconds="1"/> <sleep seconds="1"/>
<mkdir dir="${out}"/> <mkdir dir="${out}"/>
<mkdir dir="${tmpRetour}"/>
<for param="inputFile"> <for param="inputFile">
<path> <path>
...@@ -29,7 +32,7 @@ ...@@ -29,7 +32,7 @@
<sequential> <sequential>
<local name="filename"/> <local name="filename"/>
<basename property="filename" file="@{inputFile}"/> <basename property="filename" file="@{inputFile}"/>
<antcall target="UnzipHdocFile"> <antcall target="UnzipHdocFile">
<param name="filename" value="${filename}"/> <param name="filename" value="${filename}"/>
</antcall> </antcall>
...@@ -38,7 +41,9 @@ ...@@ -38,7 +41,9 @@
<param name="filename" value="${filename}"/> <param name="filename" value="${filename}"/>
</antcall> </antcall>
<antcall target="MakeOCF"/> <antcall target="MakeOCF">
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="MakeOPF"> <antcall target="MakeOPF">
<param name="filename" value="${filename}"/> <param name="filename" value="${filename}"/>
...@@ -48,6 +53,15 @@ ...@@ -48,6 +53,15 @@
<param name="filename" value="${filename}"/> <param name="filename" value="${filename}"/>
</antcall> </antcall>
<antcall target="ZipEpubFile">
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="ValidateOutput">
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="CleanTmp"/>
</sequential> </sequential>
</for> </for>
</target> </target>
...@@ -72,25 +86,49 @@ ...@@ -72,25 +86,49 @@
</target> </target>
<target name="MakeOCF"> <target name="MakeOCF">
<mkdir dir="${out}/META-INF"/> <mkdir dir="${tmpRetour}/META-INF"/>
<mkdir dir="${out}/oebps"/> <mkdir dir="${tmpRetour}/oebps"/>
<copy file="${file}/mimetype" todir="${out}"/> <copy file="${file}/mimetype" todir="${tmpRetour}"/>
<copy file="${file}/container.xml" todir="${out}/META-INF"/> <copy file="${file}/container.xml" todir="${tmpRetour}/META-INF"/>
</target> </target>
<target name="MakeOPF"> <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>
<target name="MakeOPS"> <target name="MakeOPS">
<mkdir dir="${out}/oebps/images"/> <mkdir dir="${tmpRetour}/oebps/images"/>
<copy todir="${out}/oebps/images"> <copy todir="${tmpRetour}/oebps/images">
<fileset dir="${tmp}/${filename}/decompressedHdoc/re" includes="**"/> <fileset dir="${tmp}/${filename}/decompressedHdoc/re" includes="**"/>
</copy> </copy>
<mkdir dir="${out}/oebps/styles"/> <mkdir dir="${tmpRetour}/oebps/styles"/>
<mkdir dir="${out}/oebps/chapitres"/> <mkdir dir="${tmpRetour}/oebps/chapitres"/>
<xslt in="${tmp}/${filename}/decompressedHdoc/content.xml" out="${out}/oebps/tableDesMatieres.ncx" classpath="${lib}/saxon9he.jar" style="${xsl}/tdmncx.xsl"/> <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>
<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> </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 @@ ...@@ -3,12 +3,13 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs" exclude-result-prefixes="xs"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml" xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
xmlns="http://www.daisy.org/z3986/2005/ncx/"
version="2.0"> version="2.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/> <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="html"> <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> <head>
<meta content="org-example-5059463624137734586" name="dtb:uid"/> <meta content="org-example-5059463624137734586" name="dtb:uid"/>
</head> </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