Commit 92eca99d authored by Aghiles's avatar Aghiles

Merge branch 'master' of https://gitlab.utc.fr/crozatst/hdoc

parents 9ffa44a4 1fee33fc
...@@ -6,8 +6,8 @@ http://www.gnu.org/licenses/gpl-3.0.txt ...@@ -6,8 +6,8 @@ http://www.gnu.org/licenses/gpl-3.0.txt
## Credits ## Credits
- 2016 - 2016
- - Etienne Chognard - Etienne Chognard
- - Fabien Boucaud - Fabien Boucaud
- 2015 - 2015
- Jean-Côme Douteau - Jean-Côme Douteau
- Gabrielle Rit - Gabrielle Rit
...@@ -85,4 +85,4 @@ Currently available on: https://framemo.org/framapad_to_opale ...@@ -85,4 +85,4 @@ Currently available on: https://framemo.org/framapad_to_opale
- br -> p - br -> p
## Capitalisation ## Capitalisation
Using regular expression with xsl is a good way to parse a non xml file. Using regular expression with xsl is a good way to parse a non xml file.
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="myantce" default="main"> <project basedir="." name="myantce" default="main">
<property file="etherpad_to_hdoc.properties"/> <property file="framapad_to_hdoc.properties"/>
<!-- import classes --> <!-- import classes -->
<taskdef resource="net/sf/antcontrib/antlib.xml"/> <taskdef resource="net/sf/antcontrib/antlib.xml"/>
<taskdef name="htmlcleaner" classname="org.htmlcleaner.HtmlCleanerForAnt"/> <taskdef name="htmlcleaner" classname="org.htmlcleaner.HtmlCleanerForAnt"/>
......
@echo off @echo off
set lib=lib set lib=lib
set ant=etherpad_to_hdoc.ant set ant=framapad_to_hdoc.ant
set antparam=-Dprogram.param=%1 set antparam=-Dprogram.param=%1
set scJarList=%lib%\* set scJarList=%lib%\*
......
#!/bin/sh #!/bin/sh
lib="lib" lib="lib"
ant="etherpad_to_hdoc.ant" ant="framapad_to_hdoc.ant"
antparam="-Dprogram.param=$1" antparam="-Dprogram.param=$1"
#Recherche de java et controle que se soit une version SUN #Recherche de java et controle que se soit une version SUN
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="myantce" default="main"> <project basedir="." name="myantce" default="main">
<property file="etherpad_to_opale.properties"/> <property file="framapad_to_opale.properties"/>
<!-- CHECK FOR OS FAMILY --> <!-- CHECK FOR OS FAMILY -->
<condition property="is_windows"> <condition property="is_windows">
<os family="windows"/> <os family="windows"/>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<include name="*.html"/> <include name="*.html"/>
</fileset> </fileset>
</copy> </copy>
<exec dir="../etherpad_to_hdoc" executable="run.bat"/> <exec dir="../framapad_to_hdoc" executable="run.bat"/>
</target> </target>
<target name="to_hdoc_unix" if="${is_unix}"> <target name="to_hdoc_unix" if="${is_unix}">
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
<include name="*.html"/> <include name="*.html"/>
</fileset> </fileset>
</copy> </copy>
<exec executable="/bin/bash" dir="../etherpad_to_hdoc"> <exec executable="/bin/bash" dir="../framapad_to_hdoc">
<arg value="../etherpad_to_hdoc/run.sh"/> <arg value="../framapad_to_hdoc/run.sh"/>
</exec> </exec>
</target> </target>
...@@ -90,4 +90,4 @@ ...@@ -90,4 +90,4 @@
<antcall target="to_opale_windows"/> <antcall target="to_opale_windows"/>
<antcall target="to_opale_end"/> <antcall target="to_opale_end"/>
</target> </target>
</project> </project>
\ No newline at end of file
...@@ -5,8 +5,8 @@ xsl = ${basedir}/xsl ...@@ -5,8 +5,8 @@ xsl = ${basedir}/xsl
lib = ${basedir}/lib lib = ${basedir}/lib
log = ${basedir}/log log = ${basedir}/log
eth_in = ../etherpad_to_hdoc/input eth_in = ../framapad_to_hdoc/input
eth_out = ../etherpad_to_hdoc/output eth_out = ../framapad_to_hdoc/output
opa_in = ../hdoc_to_opale/input opa_in = ../hdoc_to_opale/input
opa_out = ../hdoc_to_opale/output opa_out = ../hdoc_to_opale/output
rootfilename = content.xml rootfilename = content.xml
\ No newline at end of file
@echo off @echo off
set lib=lib set lib=lib
set ant=etherpad_to_opale.ant set ant=framapad_to_opale.ant
set antparam=-Dprogram.param=%1 set antparam=-Dprogram.param=%1
set scJarList=%lib%\* set scJarList=%lib%\*
......
#!/bin/sh #!/bin/sh
lib="lib" lib="lib"
ant="etherpad_to_opale.ant" ant="framapad_to_opale.ant"
antparam="-Dprogram.param=$1" antparam="-Dprogram.param=$1"
#Recherche de java et controle que se soit une version SUN #Recherche de java et controle que se soit une version SUN
......
libdir=${basedir}/lib lib=${basedir}/lib
rngdir=${basedir}/rng log=${basedir}/log
xsldir=${basedir}/xsl xsl=${basedir}/xsl
srcdir=${basedir}/in in=${basedir}/input
outdir=${basedir}/out out=${basedir}/output
InputPath=${basedir}/input tmp=${basedir}/tmp
OutputPath=${basedir}/output \ No newline at end of file
...@@ -3,46 +3,42 @@ ...@@ -3,46 +3,42 @@
<taskdef resource="net/sf/antcontrib/antlib.xml"/> <taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property name="in" location="${basedir}/input"/> <property file="build.properties"/>
<property name="out" location="${basedir}/output"/>
<property name="tmp" location="${basedir}/tmp"/> <target name="convert">
<property name="xsl" location="${basedir}/xsl"/> <!-- Preparation for the file transformation : delete old folders and create new folders -->
<property name="lib" location="${basedir}/lib"/> <mkdir dir="${tmp}"/>
<property name="log" location="${basedir}/log"/> <delete dir="${out}" failonerror="false"/>
<mkdir dir="${out}"/>
<target name="convert"> <delete dir="${log}" failonerror="false"/>
<echo message="DEBUT"/> <mkdir dir="${log}"/>
<echo message="DEBUT"/>
<!-- Convert all the hdoc files in the directory ${in} to data xml files that will be imported to basex later.
Fonctions "UnzipHdocFile" and "content" will be called. -->
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
</path>
<delete dir="${tmp}" failonerror="false"/> <sequential>
<sleep seconds="1"/> <local name="filename"/>
<mkdir dir="${tmp}"/> <basename property="filename" file="@{inputFile}"/>
<delete dir="${out}" failonerror="false"/>
<sleep seconds="1"/>
<mkdir dir="${out}"/>
<delete dir="${log}" failonerror="false"/>
<sleep seconds="1"/>
<mkdir dir="${log}"/>
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
</path>
<antcall target="UnzipHdocFile">
<sequential> <param name="filename" value="${filename}"/>
<local name="filename"/> </antcall>
<basename property="filename" file="sample.hdoc"/>
<antcall target="content">
<antcall target="UnzipHdocFile"> <param name="filename" value="${filename}"/>
<param name="filename" value="${filename}"/> </antcall>
</antcall> <echo message="FIN"/>
</sequential>
<antcall target="content"> </for>
<param name="filename" value="${filename}"/>
</antcall> <!-- Clean-->
<delete dir="${tmp}" failonerror="false"/>
</sequential> </target>
<echo message="FIN"/>
</target>
<target name="UnzipHdocFile"> <target name="UnzipHdocFile">
<!-- Unzip the input hdoc file. Decompressed folder is named "decompressedHdoc" : this name is the only one which <!-- Unzip the input hdoc file. Decompressed folder is named "decompressedHdoc" : this name is the only one which
...@@ -50,15 +46,16 @@ ...@@ -50,15 +46,16 @@
<unzip src="${in}/${filename}" dest="${tmp}/${filename}/decompressedHdoc"/> <unzip src="${in}/${filename}" dest="${tmp}/${filename}/decompressedHdoc"/>
<chmod dir="${tmp}/${filename}/decompressedHdoc" perm="777"/> <chmod dir="${tmp}/${filename}/decompressedHdoc" perm="777"/>
<echo message="${tmp}/${filename}/decompressedHdoc"/> <echo message="${tmp}/${filename}/decompressedHdoc"/>
<sleep seconds="1"/>
</target> </target>
<target name="content" > <target name="content" >
<xslt in="${tmp}/${filename}/decompressedHdoc/content.xml" out="${tmp}/${filename}/generateContentPath.xml" style="${xsl}/transformation.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"> <!-- Transformation of a xml file decompressed from hdoc file to data xml file to be imported to basex.
<param name="filename" expression="${filename}"/> The transformation will be done in terms of the xsl file in ${xsl}.-->
<param name="lib" expression="${lib}"/> <xslt in="${tmp}/${filename}/decompressedHdoc/content.xml" out="${out}/${filename}_data.xml" style="${xsl}/transformation.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison">
</xslt> <param name="filename" expression="${filename}"/>
<param name="lib" expression="${lib}"/>
</xslt>
<echo message="${filename}" />
</target> </target>
</project> </project>
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<titre><xsl:value-of select="./h:title"/></titre> <titre><xsl:value-of select="./h:title"/></titre>
</xsl:template> </xsl:template>
<xsl:template match="h:body" mode="title"> <xsl:template match="h:body" mode="title">
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
\ No newline at end of file
...@@ -18,20 +18,25 @@ Credits ...@@ -18,20 +18,25 @@ Credits
Presentation Presentation
------------ ------------
"Hdoc to Epub" is an hdoc converter to epub files. It's a set of ANT scripts and XSL files
Dependencies Dependencies
------------ ------------
There's no particular dependencies needed to run the converter.
User Documentation User Documentation
------------------ ------------------
### Scenario
La personne possède un hdoc et voudrait le convertir en epub. Il se dirige vers le site hdoc et télécharge le zip. Il extrait le zip et se rend vers le dossier hdoc_to_epub. Il lit le README.md et suit les directives pour obtenir son format epub. Pour cela, il doit coller son hdoc dans le dossier input et lancer l'exécutable "run". Enfin, il aura son epub dans le dossier output.
Unsupported Unsupported
----------- -----------
Known bugs Known bugs
---------- ----------
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- test.ant --> <project name="hdoc_to_epub" basedir="." default="convert">
<project>
<property name="p">Default</property> <taskdef resource="net/sf/antcontrib/antlib.xml"/>
<echo message="${p}"/> <taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask"/>
<property name="in" location="${basedir}/input"/>
<property name="out" location="${basedir}/output"/>
<property name="tmp" location="${basedir}/tmp"/>
<property name="schema" location="${basedir}/schema"/>
<target name="convert">
<delete dir="${tmp}" failonerror="false"/>
<sleep seconds="1"/>
<mkdir dir="${tmp}"/>
<delete dir="${out}" failonerror="false"/>
<sleep seconds="1"/>
<mkdir dir="${out}"/>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
</path>
<sequential>
<local name="filename"/>
<basename property="filename" file="@{inputFile}"/>
<antcall target="UnzipHdocFile">
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="ValidateInput">
<param name="filename" value="${filename}"/>
</antcall>
</sequential>
</for>
</target>
<target name="UnzipHdocFile">
<!-- Unzip the input hdoc file. Decompressed folder is named "decompressedHdoc" : this name is the only one which
refers to the hdoc file furthermore in this project. -->
<unzip src="${in}/${filename}" dest="${tmp}/${filename}/decompressedHdoc"/>
<chmod dir="${tmp}/${filename}/decompressedHdoc" perm="777"/>
</target>
<!-- Validating the XML container file -->
<target name="ValidateInput">
<trycatch property="foo" reference="bar">
<try>
<jing file="${tmp}/${filename}/decompressedHdoc/META-INF/container.xml" rngfile="${schema}/hdoc1-container.rng"></jing>
</try>
<catch>
<echo>Validation failed</echo>
</catch>
</trycatch>
</target>
</project> </project>
<?xml version="1.0" encoding="UTF-8"?>
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
ns="urn:utc.fr:ics:hdoc:container"
>
<a:documentation>This schema describes the META-INF/container.xml file for hdoc format</a:documentation>
<a:documentation>This schema is a derivation of http://www.idpf.org/epub/30/schema/ocf-container-30.rnc
from EPUB Open Container Format (http://www.idpf.org/epub/30/spec/epub30-ocf.html)
</a:documentation>
<start>
<element name="container">
<attribute name="version">
<value>1.0</value>
</attribute>
<element name="rootfiles">
<element name="rootfile">
<attribute name="full-path">
<data type="anyURI"/>
</attribute>
<attribute name="media-type">
<value>text/xml</value>
</attribute>
</element>
</element>
</element>
</start>
</grammar>
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
<xsl:stylesheet <xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"> xmlns:xs="http://www.w3.org/2001/XMLSchema"
<xsl:output method="xml" indent="yes"/> xpath-default-namespace="http://www.w3.org/1999/xhtml">
<xsl:output method="text" indent="yes"/>
<xsl:template match="html"> <xsl:template match="html">
<Helloworld/> Hello world !
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
...@@ -149,3 +149,11 @@ The opale_to_hdoc converter transcribes an Opale publication to a hdoc format. O ...@@ -149,3 +149,11 @@ The opale_to_hdoc converter transcribes an Opale publication to a hdoc format. O
The source code converter is available and can be completed in order to The source code converter is available and can be completed in order to
improve it and manage more Opale elements. improve it and manage more Opale elements.
Modified by Benoit Villain (12/12/2016)
------------------
Les divisions et les parties d'un grain n'étaient pas traitées... Contrairement à ce que mentionne le README...
J'ai donc apporté les modifications nécessaires pour que les divisions et les parties (récursives) soient bel et bien transformées en "section" hdoc.
This diff is collapsed.
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