Commit 6aa88a10 authored by Mar60's avatar Mar60

hdoc_to_lexique that works with one input file, needs to complexify the transfo xsl

parent 578d81a7
# Converter hdoc_to_lexique
In order to use this converter, follow those steps :
1. Copy your hdoc file (.scar or .zip) into the input directory.
1. Copy your hdoc file (.scar or .zip) into the input directory. Do not put more than one file into the input directory.
2. Execute the run that correspond to your OS.
3. You will find the result into the output directory.
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="clean" basedir=".">
<property file="build.properties"/>
<!-- <taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath>
<pathelement location="${libdir}/jing.jar"/>
</classpath>
</taskdef> -->
<target name="init">
<mkdir dir="${outdir}"/>
<chmod perm="777" dir="${outdir}"></chmod>
<mkdir dir="${srcdir}"/>
<chmod perm="777" dir="${srcdir}"></chmod>
</target>
<project name="hdoc_to_lexique" default="clean">
<target name="unzipSource" depends="init">
<fileset dir="${InputPath}" id="inputsId">
<include name="*.zip"/>
<include name="*.scar"/>
</fileset>
<property name="nameInputsId" refid="inputsId"/>
<echo>Fichier en entree : ${nameInputsId}</echo>
<unzip src="${InputPath}/${nameInputsId}" dest="${srcdir}/${nameInputsId}"></unzip>
</target>
<target name="buildOutput" depends="unzipSource">
<xslt classpath="${libdir}/saxon9he.jar" style="${xsldir}/hdoc_to_lexique.xsl" basedir="${srcdir}" destdir="${outdir}" followsymlinks="false" extension=".term">
<include name="**/*.xml"/>
</xslt>
<!--<jing rngfile="${rngdir}/op_glos.rng">
<fileset dir="${outdir}">
<include name="**/*.ref"/>
</fileset>
</jing>-->
</target>
<target name="exportOutput" depends="buildOutput">
<copy file="lexique.wspmeta" tofile="${outdir}/.wspmeta"></copy>
<copydir src="${outdir}/${nameInputsId}" dest="${OutputPath}/lexique-${nameInputsId}"></copydir>
<!--<zip basedir="${outdir}" destfile="${OutputPath}/opale-${nameInputsId}" encoding="UTF-8"></zip>-->
</target>
<target name="clean" depends="exportOutput">
<delete dir="${srcdir}" />
<delete dir="${outdir}" />
</target>
<property file="build.properties"/>
</project>
<target name="init">
<mkdir dir="${srcdir}"/>
<chmod perm="777" dir="${srcdir}"></chmod>
<mkdir dir="${outdir}"/>
<chmod perm="777" dir="${outdir}"></chmod>
<delete dir="${OutputPath}" />
<mkdir dir="${OutputPath}"/>
<chmod perm="777" dir="${OutputPath}"></chmod>
</target>
<target name="unzipSource" depends="init">
<fileset dir="${InputPath}" id="inputsId">
<include name="*.zip"/>
<include name="*.scar"/>
</fileset>
<property name="nameInputsId" refid="inputsId"/>
<echo>Fichier en entree : ${nameInputsId}</echo>
<unzip src="${InputPath}/${nameInputsId}" dest="${srcdir}/${nameInputsId}"></unzip>
</target>
<target name="buildContainer" depends="unzipSource">
<!--launches the XSLT find_content to retrieve the content path-->
<xslt in="${srcdir}/${nameInputsId}/META-INF/container.xml" out="get_content.ant" style="${xsldir}/find_content.xsl"/>
<chmod file="get_content.ant" perm="777"/>
<echo>5</echo>
<!--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 copy into the output directory-->
<!--<zip basedir="result" destfile="${OutputScarPath}"/>-->
<echo>6</echo>
<!-- TODO change ${outdir}/result-->
<copydir src="${outdir}" dest="${OutputPath}/lexique-result"></copydir>
<echo>6</echo>
</target>
<target name="clean" depends="buildContainer">
<delete file="get_content.ant"/>
<delete file="get_ressources.ant"/>
<delete dir="${srcdir}" />
<delete dir="${outdir}" />
</target>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--find_content.xsl creates a ANT file get_content-->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
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:output method="xml" indent="yes"/>
<xsl:template match="h:container">
<project name="hdoc_to_lexique" default="main">
<property file="build.properties"/>
<target name="main">
<!--<copy file="output/.wspmeta" todir="result"/>-->
<xsl:apply-templates/>
</target>
</project>
</xsl:template>
<xsl:template match="h:rootfiles">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="h:rootfile">
<xsl:variable name="path" select="@full-path"/>
<!--the ANT runs the XSLT get_ressources then the ANT created by it-->
<xslt in="${{srcdir}}/${{nameInputsId}}/{$path}" out="get_ressources.ant" style="${{xsldir}}/find_ressources.xsl"/>
<chmod file="get_ressources.ant" perm="777"/>
<ant antfile="get_ressources.ant"/>
<!--the ANT runs the main XSLT transfo-->
<!--TODO change this in order to perform transfo and get multiple out file as .term each one for a specific definition-->
<xslt in="${{srcdir}}/${{nameInputsId}}/{$path}" out="${{outdir}}/content.term" style="${{xsldir}}/transfo.xsl"/>
</xsl:template>
</xsl:stylesheet>
<!--find_ressources.xsl creates a ANT file get_ressources-->
<!--the ANT copies all audio files, images and objects used in the content to convert-->
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h="http://www.utc.fr/ics/hdoc/xhtml"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="h:html">
<project name="hdoc_to_lexique" default="main">
<target name="main">
<xsl:apply-templates select="h:body"/>
</target>
</project>
</xsl:template>
<xsl:template match="h:body">
<xsl:apply-templates select="h:section"/>
</xsl:template>
<xsl:template match="h:section">
<xsl:apply-templates select="h:div"/>
<xsl:apply-templates select="h:section"/>
</xsl:template>
<xsl:template match="h:div">
<xsl:apply-templates select="h:section"/>
<xsl:apply-templates select="h:img"/>
<xsl:apply-templates select="h:object"/>
<xsl:apply-templates select="h:audio"/>
</xsl:template>
<xsl:template match="h:img">
<xsl:variable name="src" select="@src"/>
<copy file="${srcdir}/${nameInputsId}/{$src}" tofile="${outdir}/{$src}"/>
</xsl:template>
<xsl:template match="h:object">
<xsl:variable name="data" select="@data"/>
<copy file="${srcdir}/${nameInputsId}/{$data}" tofile="${outdir}/{$data}"/>
</xsl:template>
<xsl:template match="h:audio">
<xsl:variable name="src" select="@src"/>
<copy file="${srcdir}/${nameInputsId}/{$src}" tofile="${outdir}/{$src}"/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
......@@ -35,5 +35,29 @@
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>-->
</xsl:template>
<!-- <xsl:template match="/hodoc:html/hodoc:body">
<xsl:for-each select="/hodoc:html/hodoc:body/hodoc:section">
<xsl:result-document href="section{position()}.html"> TODO change name of the file
<sc:item xmlns:sc="http://www.utc.fr/ics/scenari/v3/core">
<lx:term xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive" xmlns:lx="scpf.org:lexicon">
<lx:termM>
<sp:name><xsl:value-of select="hodoc:h2[@span='titre_def']"></xsl:value-of></sp:name>
</lx:termM>
<sp:def>
<lx:definition>
<sp:desc>
<lx:defTxt>
<xsl:apply-templates select="hodoc:p[@span='def_content']"></xsl:apply-templates>
</lx:defTxt>
</sp:desc>
</lx:definition>
</sp:def>
</lx:term>
</sc:item>
</xsl:result-document>
</xsl:for-each>
</xsl:template>-->
</xsl:stylesheet>
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