Commit d23769ac authored by Decorde Jeffrey's avatar Decorde Jeffrey

Hdoc to Opale conversion with antce

parent e11606ad
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="hdoc_to_opale" basedir="." default="convert">
<property name="in" location="${basedir}/input"/>
<property name="out" location="${basedir}/output"/>
<property name="tmp" location="${basedir}/tmp"/>
<property name="xsl" location="${basedir}/xsl"/>
<property name="lib" location="${basedir}/lib"/>
<property name="log" location="${basedir}/log"/>
<property name="schema" location="${basedir}/schema"/>
<property name="bibtex" location="${basedir}/bibtex_to_opale"/>
<property file="global.properties"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath>
<pathelement location="lib/jing.jar"/>
</classpath>
</taskdef>
<target name="convert">
<!-- This is the main target : it is called whether by the project (as the default target) or by the user/converter
website, if specified in the command line. Basically, this target consists in several targets/ant buildfiles calls. -->
<antcall target="CleanDirectory"/>
<antcall target="UnzipHdocFile"/>
<antcall target="ValidateInput" />
<antcall target="FindContentFiles"/>
<ant antfile="${tmp}/generateContentPath.xml"/>
<antcall target="ValidateOutput"/>
<antcall target="DivideOutput"/>
<antcall target="ZipOutput"/>
<antcall target="ZipDividedOutput"/>
<antcall target="CleanDirectory"/>
</target>
<target name="CleanDirectory">
<delete>
<fileset dir="${tmp}">
<include name="**/*"/>
</fileset>
</delete>
</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 dest="${tmp}/decompressedHdoc">
<fileset dir="${in}">
<include name="**/*.hdoc"/>
</fileset>
</unzip>
<chmod dir="${tmp}/decompressedHdoc" perm="777"/>
</target>
<target name="FindContentFiles">
<!-- Finds the absolute path of container.xml and applies transformation0.xsl on it.-->
<first id="first">
<fileset dir="${tmp}/decompressedHdoc/META-INF" includes="**/container.xml"/>
</first>
<xslt in="${toString:first}" out="${tmp}/generateContentPath.xml" style="${xsl}/transformation0.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison" />
<chmod file="${tmp}/generateContentPath.xml" perm="777"/>
</target>
<target name="ZipOutput">
<copy file="${bibtex}/.wspmeta" todir="${tmp}/decompressedOpale"/>
<mkdir dir="${tmp}/decompressedOpale/res"/>
<ant antfile="${tmp}/moveRessourceFiles.xml"/>
<zip basedir="${tmp}/decompressedOpale" destfile="${out}/output.scar" encoding="UTF-8"/>
</target>
<target name="ZipDividedOutput">
<copy file="${bibtex}/.wspmeta" todir="${tmp}/decompressedOpaleDivided"/>
<copy todir="${tmp}/decompressedOpaleDivided/res" >
<fileset dir="${tmp}/decompressedOpale/res" includes="**"/>
</copy>
<copy todir="${tmp}/decompressedOpaleDivided/references" >
<fileset dir="${tmp}/decompressedOpale/references" includes="**"/>
</copy>
<zip basedir="${tmp}/decompressedOpaleDivided" destfile="${out}/outdividedOutput.scar" encoding="UTF-8"/>
</target>
<!-- Validating the XML container file -->
<target name="ValidateInput">
<jing file="${tmp}/decompressedHdoc/META-INF/container.xml" rngfile="${schema}/hdoc1-container.rng"></jing>
</target>
<!-- Validating the XML output -->
<target name="ValidateOutput">
<jing file="${tmp}/decompressedOpale/main.xml" rngfile="${schema}/op_ue.rng"></jing>
</target>
<target name="DivideOutput">
<mkdir dir="${tmp}/decompressedOpaleDivided"/>
<!-- Adding IDS to the general output file -->
<xslt
in="${tmp}/decompressedOpale/main.xml"
out="${tmp}/outputWithCourseUcIds.xml"
style="${xsl}/addCourseUcIds.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<!-- Generating the root file (with refs to other files) -->
<xslt
in="${tmp}/outputWithCourseUcIds.xml"
out="${tmp}/decompressedOpaleDivided/main.xml"
style="${xsl}/addCourseUcReferences.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<!-- Generating the ANT file that will copy the files -->
<xslt
in="${tmp}/outputWithCourseUcIds.xml"
out="${tmp}/exportUnits.ant"
style="${xsl}/prepareCourseUcCopies.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<!-- Executing that ANT file -->
<ant antfile="${tmp}/exportUnits.ant"/>
</target>
</project>
@echo off
set lib=lib
set ant=myantce.ant
set antparam=-Dprogram.param=%1
set scJarList=%lib%\*
java.exe -classpath "%scJarList%" -Xmx150m org.apache.tools.ant.Main -buildfile %ant% %antparam%
pause
REM start /MIN java.exe -classpath "%scJarList%" -Xmx150m org.apache.tools.ant.Main -buildfile %ant% %antparam%
#!/bin/sh
lib="lib"
ant="myantce.ant"
antparam="-Dprogram.param=$1"
#Recherche de java et controle que se soit une version SUN
vJavaCmd="java"
xCheckJava () {
vInputVarName=\$"$1"
vInputVarVal=`eval "expr \"$vInputVarName\" "`
if [ -z "$vInputVarVal" ];then
eval "$1=false"
return
fi
vSunJavaFound=`$vInputVarVal -version 2>&1 | grep -Eo -m 1 "(HotSpot)|(OpenJDK)"`
if [ "$vSunJavaFound" != "HotSpot" ] && [ "$vSunJavaFound" != "OpenJDK" ] ; then
eval "$1=false"
return
fi
}
xCheckJava vJavaCmd
if [ "$vJavaCmd" = "false" ]; then
vJavaCmd="$JAVA_HOME/bin/java"
xCheckJava vJavaCmd
if [ "$vJavaCmd" = "false" ]; then
echo "ERREUR: JRE de SUN introuvable. Veuillez déclarer la variable d'environnement JAVA_HOME."
exit 1
fi
fi
#Lancer la commande
scJarList="$lib/*"
$vJavaCmd -classpath "$scJarList:" -Xmx150m org.apache.tools.ant.Main -buildfile $ant $antparam
......@@ -9,7 +9,7 @@
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<!-- The ID of the courseUc element that needs to be copied has to be passed here -->
<xsl:param name="elementid" xsl:required="yes" xsl:as="xsl:string"/>
<xsl:param name="elementid"/>
<xsl:template match="sc:item">
<xsl:apply-templates select=".//sp:courseUc"/>
......@@ -18,9 +18,9 @@
<xsl:template match="sp:courseUc[@data-export-id = $elementid]">
<sc:item>
<!-- Once we are in the right courseUc, we can just copy everything -->
<xsl:copy-of select="./*"/>
<xsl:copy-of select="./*"/>
</sc:item>
</xsl:template>
<xsl:template match="*"/>
</xsl:stylesheet>
\ No newline at end of file
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:h="http://www.utc.fr/ics/hdoc/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
>
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<!-- This template matches the root and create a ANT project, the root of any ANT buildfile. -->
<xsl:template match="h:html">
<project name="moveRessourceFiles" basedir="." default="moveRessourceFiles">
<property file="global.properties"/>
<target name="moveRessourceFiles">
<xsl:apply-templates select="./*"/>
</target>
</project>
</xsl:template>
<!-- These templates guides XSL's motor. -->
<xsl:template match="h:body">
<xsl:apply-templates select="./h:section"/>
</xsl:template>
<xsl:template match="h:section">
<xsl:apply-templates select="./h:section | ./h:div"/>
</xsl:template>
<xsl:template match="h:div">
<xsl:apply-templates select="./h:img | ./h:audio | ./h:video | ./h:object"/>
</xsl:template>
<!-- Targeted markups. -->
<xsl:template match="h:img">
<copy tofile="${{tmpdir}}/decompressedOpale/res/{./@src}" file="${{tmpdir}}/decompressedHdoc/{./@src}"/>
</xsl:template>
<xsl:template match="h:audio">
<copy tofile="${{tmpdir}}/decompressedOpale/res/{./@src}" file="${{tmpdir}}/decompressedHdoc/{./@src}"/>
</xsl:template>
<xsl:template match="h:video">
<copy tofile="${{tmpdir}}/decompressedOpale/res/{./@src}" file="${{tmpdir}}/decompressedHdoc/{./@src}"/>
</xsl:template>
<xsl:template match="h:object">
<copy tofile="${{tmpdir}}/decompressedOpale/res/{./@data}" file="${{tmpdir}}/decompressedHdoc/{./@data}"/>
</xsl:template>
<!-- These markups are matched in order to minimize "apply-templates" side-effects (i.e. their contents are not relevant for this transformation). -->
<xsl:template match="h:head"/>
<xsl:template match="h:p"/>
<xsl:template match="h:em"/>
<xsl:template match="h:i"/>
<xsl:template match="h:span"/>
<xsl:template match="h:a"/>
<xsl:template match="h:ul"/>
<xsl:template match="h:ol"/>
<xsl:template match="h:li"/>
<xsl:template match="h:table"/>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:h="http://www.utc.fr/ics/hdoc/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
>
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<!-- This template matches the root and create a ANT project, the root of any ANT buildfile. -->
<xsl:template match="h:html">
<project name="moveRessourceFiles" basedir="." default="moveRessourceFiles">
<property file="global.properties"/>
<target name="moveRessourceFiles">
<xsl:apply-templates select="./*"/>
</target>
</project>
</xsl:template>
<!-- These templates guides XSL's motor. -->
<xsl:template match="h:body">
<xsl:apply-templates select="./h:section"/>
</xsl:template>
<xsl:template match="h:section">
<xsl:apply-templates select="./h:section | ./h:div"/>
</xsl:template>
<xsl:template match="h:div">
<xsl:apply-templates select="./h:img | ./h:audio | ./h:video | ./h:object"/>
</xsl:template>
<!-- Targeted markups. -->
<xsl:template match="h:img">
<copy tofile="${{tmp}}/decompressedOpale/res/{./@src}" file="${{tmp}}/decompressedHdoc/{./@src}"/>
</xsl:template>
<xsl:template match="h:audio">
<copy tofile="${{tmp}}/decompressedOpale/res/{./@src}" file="${{tmp}}/decompressedHdoc/{./@src}"/>
</xsl:template>
<xsl:template match="h:video">
<copy tofile="${{tmp}}/decompressedOpale/res/{./@src}" file="${{tmp}}/decompressedHdoc/{./@src}"/>
</xsl:template>
<xsl:template match="h:object">
<copy tofile="${{tmp}}/decompressedOpale/res/{./@data}" file="${{tmp}}/decompressedHdoc/{./@data}"/>
</xsl:template>
<!-- These markups are matched in order to minimize "apply-templates" side-effects (i.e. their contents are not relevant for this transformation). -->
<xsl:template match="h:head"/>
<xsl:template match="h:p"/>
<xsl:template match="h:em"/>
<xsl:template match="h:i"/>
<xsl:template match="h:span"/>
<xsl:template match="h:a"/>
<xsl:template match="h:ul"/>
<xsl:template match="h:ol"/>
<xsl:template match="h:li"/>
<xsl:template match="h:table"/>
</xsl:stylesheet>
......@@ -9,10 +9,17 @@
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="sc:item">
<project name="copy-ucs" default="main">
<project name="copy-ucs" basedir=".." default="main">
<property name="in" location="${{basedir}}/input"/>
<property name="out" location="${{basedir}}/output"/>
<property name="tmp" location="${{basedir}}/tmp"/>
<property name="xsl" location="${{basedir}}/xsl"/>
<property name="lib" location="${{basedir}}/lib"/>
<property name="log" location="${{basedir}}/log"/>
<property name="schema" location="${{basedir}}/schema"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath>
<pathelement location="lib/jing.jar"/>
<pathelement location="../lib/jing.jar"/>
</classpath>
</taskdef>
......@@ -26,16 +33,16 @@
<xsl:template match="sp:courseUc">
<xslt
in="${{tmpdir}}/outputWithCourseUcIds.xml"
out="${{tmpdir}}/decompressedOpaleDivided/{@data-export-file}"
style="copyCourseUc.xsl"
in="${{tmp}}/outputWithCourseUcIds.xml"
out="${{tmp}}/decompressedOpaleDivided/{@data-export-file}"
style="${{xsl}}/copyCourseUc.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
>
<param name="elementid" expression="{@data-export-id}"/>
</xslt>
<jing file="${{tmpdir}}/decompressedOpaleDivided/{@data-export-file}" rngfile="schema/op_expUc.rng"></jing>
<jing file="${{tmp}}/decompressedOpaleDivided/{@data-export-file}" rngfile="${{schema}}/op_expUc.rng"></jing>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:c="urn:utc.fr:ics:hdoc:container"
>
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="c:container">
<project name="getContentFileAndTransformIt" basedir="." default="start">
<property file="global.properties"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath>
<pathelement location="lib/jing.jar"/>
</classpath>
</taskdef>
<xsl:apply-templates select="./c:rootfiles"/>
</project>
</xsl:template>
<xsl:template match="c:rootfiles">
<target name="start">
<jing file="${{tmpdir}}/decompressedHdoc/{c:rootfile/@full-path}" rngfile="schema/hdoc1-xhtml.rng"></jing>
<xslt
in="${{tmpdir}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmpdir}}/moveRessourceFiles.xml"
style="moveRessourceFiles.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<chmod file="${{tmpdir}}/moveRessourceFiles.xml" perm="777"/>
<xslt
in="${{tmpdir}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmpdir}}/decompressedOpale/main.xml"
style="transformation2.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<chmod file="${{tmpdir}}/decompressedOpale/main.xml" perm="777"/>
<!-- Finding references and converting them -->
<xslt
in="${{tmpdir}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmpdir}}/convertReferences.xml"
style="prepareReferencesConversions.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<ant antfile="${{tmpdir}}/convertReferences.xml"/>
</target>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:c="urn:utc.fr:ics:hdoc:container"
>
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="c:container">
<project name="getContentFileAndTransformIt" basedir="." default="start">
<property file="global.properties"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath>
<pathelement location="../lib/jing.jar"/>
</classpath>
</taskdef>
<xsl:apply-templates select="./c:rootfiles"/>
</project>
</xsl:template>
<xsl:template match="c:rootfiles">
<target name="start">
<jing file="${{tmp}}/decompressedHdoc/{c:rootfile/@full-path}" rngfile="${{schema}}/hdoc1-xhtml.rng"></jing>
<xslt
in="${{tmp}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/moveRessourceFiles.xml"
style="${{xsl}}/moveRessourceFiles.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<chmod file="${{tmp}}/moveRessourceFiles.xml" perm="777"/>
<xslt
in="${{tmp}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/decompressedOpale/main.xml"
style="${{xsl}}/transformation2.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<chmod file="${{tmp}}/decompressedOpale/main.xml" perm="777"/>
<!-- Finding references and converting them -->
<xslt
in="${{tmp}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/convertReferences.xml"
style="${{xsl}}/prepareReferencesConversions.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<ant antfile="${{tmp}}/convertReferences.xml"/>
</target>
</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