Commit 796ebb40 authored by Jean Vintache's avatar Jean Vintache

pull master

parents 580791ac 42f770d3
Pour réaliser votre conversion vous devez ajouter un fichier .hdoc dans le dossier input. Veillez à n'en placer qu'un seul dedans. Ensuite il suffit d'appeler le script (.bat ou .sh).
\ No newline at end of file
Ce convertisseur permet de convertir des fichiers du format Hdoc (.hdoc) en contenus Optim de type papier (.paper) ou diaporama (.slideshow)
Il y a deux façons de réaliser votre conversion:
- Lancer le script run. Dans ce cas vous devez ajouter votre fichier .hdoc dans le dossier input. Veillez à ne placer qu'un seul fichier dans ce dossier. Le format par défaut utilisé pour le fichier cible est le type papier.
- En ligne de commande:
ant -buildfile hdoc_to_optim.ant
Vous pouvez spécifier le fichier input, avec le paramètre -DInputFile, et le format de sortie avec le paramètre -DDocType (paper ou slideshow). Les deux paramètres sont optionnels.
Exemple:
ant -buildfile hdoc_to_optim.ant -DDocType slideshow -DInputFile sample.hdoc
\ No newline at end of file
<project name="hdoc_to_optim" default="convert">
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="lib/ant-contrib.jar" />
</classpath>
</taskdef>
<!-- Arguments properties -->
<property name="DocType" value="paper" />
<property name="InputFile" value="none" />
<property name="InputPath" value="input" />
<property name="OutputPath" value="output" />
<property name="OutputScarPath" value="${OutputPath}/result.scar" />
<property name="OutputScarPath" value="${OutputPath}/result.scar" />
<target name="convert">
<!-- get input hdoc file path -->
<fileset id="fileset_hdoc" dir="${InputPath}" casesensitive="yes">
<include name="*.hdoc"/>
</fileset>
<pathconvert property="HdocPath" pathsep="" refid="fileset_hdoc" />
<!--Check wether there is an input using command line or not-->
<if>
<equals arg1="${InputFile}" arg2="none" />
<then>
<!--There is no input, check the input folder-->
<echo message="The value of property InputFile is ${InputFile} ... Checking the input folder" />
<echo message="The value of property DocType is ${DocType}" />
<!-- get input hdoc file path -->
<fileset id="fileset_hdoc" dir="${InputPath}" casesensitive="yes">
<include name="*.hdoc"/>
</fileset>
<pathconvert property="HdocFile" pathsep="" refid="fileset_hdoc" />
<echo message="Executing conversion..." />
<!--unzips the hdoc to be converted-->
<unzip dest="hdoc" src ="${HdocPath}"/>
<!--gives all rights to avoid bugs-->
<chmod dir="hdoc" perm="777"/>
<!--launches the XSLT find_content to retrieve the content path-->
<xslt in="hdoc/META-INF/container.xml" out="get_content.ant" style="xsl/find_content.xsl"/>
<chmod file="get_content.ant" perm="777"/>
<!--unzips the hdoc to be converted-->
<unzip dest="hdoc" src ="${HdocFile}"/>
<!--gives all rights to avoid bugs-->
<chmod dir="hdoc" perm="777"/>
<!--launches the XSLT find_content to retrieve the content path-->
<xslt in="hdoc/META-INF/container.xml" out="get_content.ant" style="xsl/find_content.xsl">
<param name="DocumentType" expression="${DocType}"/>
</xslt>
<chmod file="get_content.ant" perm="777"/>
<!--launches the ANT get_content resulting from the previous XSLT in order to launch the conversion-->
<ant antfile="get_content.ant"/>
<!--once the conversion is complete, the result is zipped-->
<zip basedir="result" destfile="${OutputScarPath}"/>
<!--temporary files and folders are deleted-->
<delete dir="hdoc"/>
<delete dir="result"/>
<delete file="get_content.ant"/>
<delete file="get_ressources.ant"/>
<!--launches the ANT get_content resulting from the previous XSLT in order to launch the conversion-->
<ant antfile="get_content.ant"/>
<!--once the conversion is complete, the result is zipped-->
<zip basedir="result" destfile="${OutputScarPath}" encoding="UTF-8"/>
<!--temporary files and folders are deleted-->
<delete dir="hdoc"/>
<delete dir="result"/>
<delete file="get_content.ant"/>
<delete file="get_ressources.ant"/>
</then>
<else>
<!--There is an input-->
<echo message="The value of property InputFile is ${InputFile}" />
<echo message="The value of property DocType is ${DocType}" />
<echo message="Executing conversion..." />
</target>
<!--unzips the hdoc to be converted-->
<unzip dest="hdoc" src ="${InputFile}"/>
<!--gives all rights to avoid bugs-->
<chmod dir="hdoc" perm="777"/>
<!--launches the XSLT find_content to retrieve the content path-->
<xslt in="hdoc/META-INF/container.xml" out="get_content.ant" style="xsl/find_content.xsl">
<param name="DocumentType" expression="${DocType}"/>
</xslt>
<chmod file="get_content.ant" perm="777"/>
<!--launches the ANT get_content resulting from the previous XSLT in order to launch the conversion-->
<ant antfile="get_content.ant"/>
<!--once the conversion is complete, the result is zipped-->
<zip basedir="result" destfile="${OutputScarPath}" encoding="UTF-8"/>
<!--temporary files and folders are deleted-->
<delete dir="hdoc"/>
<delete dir="result"/>
<delete file="get_content.ant"/>
<delete file="get_ressources.ant"/>
</else>
</if>
</target>
</project>
\ No newline at end of file
......@@ -5,6 +5,7 @@
xmlns:h="urn:utc.fr:ics:hdoc:container"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!--<xsl:param name="destfile" required="yes" as="xs:string"/>-->
<xsl:param name="DocumentType" required="yes" as="xs:string"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="h:container">
<project name="hdoc_to_optim" default="main">
......@@ -28,6 +29,20 @@
<chmod file="get_ressources.ant" perm="777"/>
<ant antfile="get_ressources.ant"/>
<!--the ANT runs the main XSLT transfo-->
<xslt in="hdoc/{$path}" out="result/content.paper" style="xsl/transfo.xsl"/>
<xsl:choose>
<xsl:when test="$DocumentType='paper'">
<xslt in="hdoc/{$path}" out="result/content.paper" style="xsl/transfo.xsl" classpath="lib/saxon9he.jar">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
</xsl:when>
<xsl:when test="$DocumentType='slideshow'">
<xslt in="hdoc/{$path}" out="result/content.slideshow" style="xsl/transfo2.xsl" classpath="lib/saxon9he.jar">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
</xsl:when>
<xsl:otherwise>
<xsl:message> Wrong document type </xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
......@@ -13,7 +13,7 @@
</of:paper>
</sc:item>
</xsl:template>
<xsl:strip-space elements="*"/>
<!--Metadata of the head tag-->
<xsl:template match="h:head">
<of:paperM>
......@@ -88,8 +88,23 @@
<!--hdoc sections can become chapters or sections in Optim, we must differentiate the two-->
<xsl:template match="h:body/h:section">
<sp:chap>
<xsl:call-template name="sec-body"/>
<xsl:variable name="chapi" select="(.//text())[1]"/>
<xsl:message><xsl:value-of select="$chapi"/></xsl:message>
<xsl:variable name="chap">
<xsl:choose>
<xsl:when test="contains($chapi,':')">
<xsl:message>Yescontiiii!</xsl:message>
<xsl:value-of select="normalize-space(replace($chapi,':','-'))"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space($chapi)"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:message><xsl:value-of select="$chap"/></xsl:message>
<xsl:message>test</xsl:message>
<sp:chap sc:refUri="chapitres/{$chap}.section">
<xsl:call-template name="sec-body1">
<xsl:with-param name="chap" select = "$chap" />
</xsl:call-template>
</sp:chap>
</xsl:template>
......@@ -98,6 +113,33 @@
<xsl:call-template name="sec-body"/>
</sp:sec>
</xsl:template>
<xsl:template name="sec-body1">
<xsl:param name = "chap" />
<xsl:message><xsl:value-of select="$chap"/></xsl:message>
<xsl:result-document encoding="UTF-8" href="chapitres/{$chap}.section" >
<sc:item xmlns:sc="http://www.utc.fr/ics/scenari/v3/core">
<of:section>
<xsl:if test="@data-hdoc-type='introduction'">
<xsl:comment>Introduction</xsl:comment>
</xsl:if>
<xsl:if test="@data-hdoc-type='conclusion'">
<xsl:comment>Conclusion</xsl:comment>
</xsl:if>
<xsl:apply-templates select="h:header"/>
<xsl:if test="./h:div">
<sp:content>
<of:fragment>
<xsl:apply-templates select="h:div"/>
</of:fragment>
</sp:content>
</xsl:if>
<xsl:apply-templates select="h:section"/>
</of:section>
</sc:item>
</xsl:result-document>
<xsl:apply-templates select="h:footer"/>
</xsl:template>
<xsl:template name="sec-body">
<of:section>
......@@ -280,25 +322,25 @@
<!--Object-->
<xsl:template match="h:object">
<xsl:variable name="data" select="@data"/>
<sc:extBlock role="img" sc:refUri="{$data}"/>
<sc:extBlock role="img" sc:refUri="../{$data}"/>
</xsl:template>
<!--Image-->
<xsl:template match="h:img">
<xsl:variable name="src" select="@src"/>
<sc:extBlock role="img" sc:refUri="{$src}"/>
<sc:extBlock role="img" sc:refUri="../{$src}"/>
</xsl:template>
<!--Audio-->
<xsl:template match="h:audio">
<xsl:variable name="src" select="@src"/>
<sc:extBlock role="anim" sc:refUri="{$src}"/>
<sc:extBlock role="anim" sc:refUri="../{$src}"/>
</xsl:template>
<!--Video-->
<xsl:template match="h:video">
<xsl:variable name="src" select="@src"/>
<sc:extBlock role="anim" sc:refUri="{$src}"/>
<sc:extBlock role="anim" sc:refUri="../{$src}"/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
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