Commit d11314b2 authored by Decorde Jeffrey's avatar Decorde Jeffrey

Several input files handled

parent 0995aa24
......@@ -11,6 +11,7 @@
<property file="global.properties"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath>
<pathelement location="lib/jing.jar"/>
......@@ -26,7 +27,19 @@
<antcall target="ValidateInput" />
<antcall target="FindContentFiles"/>
<ant antfile="${tmp}/generateContentPath.xml"/>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
</path>
<sequential>
<local name="filename"/>
<basename property="filename" file="@{inputFile}"/>
<ant antfile="${tmp}/${filename}/generateContentPath.xml">
<property name="filename" value="${filename}"/>
</ant>
</sequential>
</for>
<antcall target="ValidateOutput"/>
<antcall target="DivideOutput"/>
......@@ -34,13 +47,12 @@
<antcall target="ZipOutput"/>
<antcall target="ZipDividedOutput"/>
<antcall target="CleanDirectory"/>
</target>
<target name="CleanDirectory">
<delete>
<fileset dir="${tmp}">
<include name="**/*"/>
<include name="*"/>
</fileset>
</delete>
</target>
......@@ -48,80 +60,143 @@
<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"/>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
</path>
<sequential>
<local name="filename"/>
<basename property="filename" file="@{inputFile}"/>
<unzip src="${in}/${filename}" dest="${tmp}/${filename}/decompressedHdoc"/>
<chmod dir="${tmp}/${filename}/decompressedHdoc" perm="777"/>
</sequential>
</for>
</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"/>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
</path>
<sequential>
<local name="filename"/>
<basename property="filename" file="@{inputFile}"/>
<first id="first">
<fileset dir="${tmp}/${filename}/decompressedHdoc/META-INF" includes="**/container.xml"/>
</first>
<xslt in="${toString:first}" out="${tmp}/${filename}/generateContentPath.xml" style="${xsl}/transformation0.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison">
<param name="filename" expression="${filename}"/>
</xslt>
<chmod file="${tmp}/${filename}/generateContentPath.xml" perm="777"/>
</sequential>
</for>
</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>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
</path>
<sequential>
<local name="filename"/>
<basename property="filename" file="@{inputFile}"/>
<copy file="${bibtex}/.wspmeta" todir="${tmp}/${filename}/decompressedOpale"/>
<mkdir dir="${tmp}/${filename}/decompressedOpale/res"/>
<ant antfile="${tmp}/${filename}/moveRessourceFiles.xml"/>
<zip basedir="${tmp}/${filename}/decompressedOpale" destfile="${out}/${filename}/output.scar" encoding="UTF-8"/>
</sequential>
</for>
</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>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
</path>
<sequential>
<local name="filename"/>
<basename property="filename" file="@{inputFile}"/>
<copy file="${bibtex}/.wspmeta" todir="${tmp}/${filename}/decompressedOpaleDivided"/>
<copy todir="${tmp}/${filename}/decompressedOpaleDivided/res" >
<fileset dir="${tmp}/${filename}/decompressedOpale/res" includes="**"/>
</copy>
<copy todir="${tmp}/${filename}/decompressedOpaleDivided/references" >
<fileset dir="${tmp}/${filename}/decompressedOpale/references" includes="**"/>
</copy>
<zip basedir="${tmp}/${filename}/decompressedOpaleDivided" destfile="${out}/${filename}/dividedOutput.scar" encoding="UTF-8"/>
</sequential>
</for>
</target>
<!-- Validating the XML container file -->
<target name="ValidateInput">
<jing file="${tmp}/decompressedHdoc/META-INF/container.xml" rngfile="${schema}/hdoc1-container.rng"></jing>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
</path>
<sequential>
<local name="filename"/>
<basename property="filename" file="@{inputFile}"/>
<jing file="${tmp}/${filename}/decompressedHdoc/META-INF/container.xml" rngfile="${schema}/hdoc1-container.rng"></jing>
</sequential>
</for>
</target>
<!-- Validating the XML output -->
<target name="ValidateOutput">
<jing file="${tmp}/decompressedOpale/main.xml" rngfile="${schema}/op_ue.rng"></jing>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
</path>
<sequential>
<local name="filename"/>
<basename property="filename" file="@{inputFile}"/>
<jing file="${tmp}/${filename}/decompressedOpale/main.xml" rngfile="${schema}/op_ue.rng"></jing>
</sequential>
</for>
</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"/>
<for param="inputFile">
<path>
<fileset dir="${in}" includes="**/*.hdoc"/>
</path>
<sequential>
<local name="filename"/>
<basename property="filename" file="@{inputFile}"/>
<mkdir dir="${tmp}/${filename}/decompressedOpaleDivided"/>
<!-- Adding IDS to the general output file -->
<xslt
in="${tmp}/${filename}/decompressedOpale/main.xml"
out="${tmp}/${filename}/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}/${filename}/outputWithCourseUcIds.xml"
out="${tmp}/${filename}/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}/${filename}/outputWithCourseUcIds.xml"
out="${tmp}/${filename}/exportUnits.ant"
style="${xsl}/prepareCourseUcCopies.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
>
<param name="filename" expression="${filename}"/>
</xslt>
<!-- Executing that ANT file -->
<ant antfile="${tmp}/${filename}/exportUnits.ant"/>
</sequential>
</for>
</target>
</project>
......@@ -10,7 +10,7 @@
<xsl:template match="h:html">
<project name="moveRessourceFiles" basedir="." default="moveRessourceFiles">
<property file="global.properties"/>
<property name="filename" location="${filename}"/>
<target name="moveRessourceFiles">
<xsl:apply-templates select="./*"/>
</target>
......@@ -30,16 +30,16 @@
<!-- Targeted markups. -->
<xsl:template match="h:img">
<copy tofile="${{tmp}}/decompressedOpale/res/{./@src}" file="${{tmp}}/decompressedHdoc/{./@src}"/>
<copy tofile="${{filename}}/decompressedOpale/res/{./@src}" file="${{filename}}/decompressedHdoc/{./@src}"/>
</xsl:template>
<xsl:template match="h:audio">
<copy tofile="${{tmp}}/decompressedOpale/res/{./@src}" file="${{tmp}}/decompressedHdoc/{./@src}"/>
<copy tofile="${{filename}}/decompressedOpale/res/{./@src}" file="${{filename}}/decompressedHdoc/{./@src}"/>
</xsl:template>
<xsl:template match="h:video">
<copy tofile="${{tmp}}/decompressedOpale/res/{./@src}" file="${{tmp}}/decompressedHdoc/{./@src}"/>
<copy tofile="${{filename}}/decompressedOpale/res/{./@src}" file="${{filename}}/decompressedHdoc/{./@src}"/>
</xsl:template>
<xsl:template match="h:object">
<copy tofile="${{tmp}}/decompressedOpale/res/{./@data}" file="${{tmp}}/decompressedHdoc/{./@data}"/>
<copy tofile="${{filename}}/decompressedOpale/res/{./@data}" file="${{filename}}/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). -->
......
......@@ -7,9 +7,10 @@
xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive"
>
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:param name="filename"/>
<xsl:template match="sc:item">
<project name="copy-ucs" basedir=".." 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"/>
......@@ -17,9 +18,10 @@
<property name="lib" location="${{basedir}}/lib"/>
<property name="log" location="${{basedir}}/log"/>
<property name="schema" location="${{basedir}}/schema"/>
<property name="filename" location="${{tmp}}/{$filename}"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath>
<pathelement location="./lib/jing.jar"/>
<pathelement location="../lib/jing.jar"/>
</classpath>
</taskdef>
......@@ -33,16 +35,15 @@
<xsl:template match="sp:courseUc">
<xslt
in="${{tmp}}/outputWithCourseUcIds.xml"
out="${{tmp}}/decompressedOpaleDivided/{@data-export-file}"
in="${{filename}}/outputWithCourseUcIds.xml"
out="${{filename}}/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="${{tmp}}/decompressedOpaleDivided/{@data-export-file}" rngfile="${{schema}}/op_expUc.rng"></jing>
<jing file="${{filename}}/decompressedOpaleDivided/{@data-export-file}" rngfile="${{schema}}/op_expUc.rng"></jing>
</xsl:template>
</xsl:stylesheet>
......@@ -11,9 +11,9 @@
<xsl:template match="h:html">
<project name="copy-references" default="main">
<property file="global.properties"/>
<property name="filename" location="${filename}"/>
<target name="main">
<mkdir dir="${{tmpdir}}/decompressedOpale/references" />
<mkdir dir="${{tmp}}/${{filename}}/decompressedOpale/references" />
<xsl:apply-templates select=".//h:a[@data-hdoc-type = 'bibtexml']"/>
</target>
......@@ -23,7 +23,7 @@
<xsl:template match="h:a[@data-hdoc-type = 'bibtexml']">
<!-- bibtex_to_opale needs the file to be in a specific folder, so let's copy it to the right place (it'd be better to modify bibtex_to_opale instead) -->
<copy file="${{tmpdir}}/decompressedHdoc/{substring-before(@href,'#')}" tofile="${{basedir}}/bibtex_to_opale/tmp/tmpHdocBib.xml"/>
<copy file="${{tmp}}/${{filename}}/decompressedHdoc/{substring-before(@href,'#')}" tofile="${{basedir}}/bibtex_to_opale/tmp/tmpHdocBib.xml"/>
<!-- Let's call bibtex_to_opale that will create a scar containing all references (*.ref) -->
<ant antfile="${{basedir}}/bibtex_to_opale/Ant/bibtex_to_opale.ant" target="convertfrombibxml">
......@@ -32,17 +32,17 @@
</ant>
<!-- Creating the directory to unzip to -->
<mkdir dir="${{tmpdir}}/decompressedOpale/references/{substring-before(@href,'.')}"/>
<mkdir dir="${{tmp}}/${{filename}}/decompressedOpale/references/{substring-before(@href,'.')}"/>
<!-- Unzipping that .scar -->
<unzip src="${{basedir}}/bibtex_to_opale/refs.scar" dest="${{tmpdir}}/decompressedOpale"/>
<unzip src="${{basedir}}/bibtex_to_opale/refs.scar" dest="${{tmp}}/${{filename}}/decompressedOpale"/>
<!-- Moving the files to the right place (because bibtex_to_opale creates a ref/folder) -->
<move file="${{tmpdir}}/decompressedOpale/ref" tofile="${{tmpdir}}/decompressedOpale/references/{substring-before(@href,'.')}"/>
<move file="${{tmp}}/${{filename}}/decompressedOpale/ref" tofile="${{tmp}}/${{filename}}/decompressedOpale/references/{substring-before(@href,'.')}"/>
<!-- Now, we only have to make sure that the references made within transformation2.xsl will point towards the right files that were created by bibtex_to_opale -->
</xsl:template>
<xsl:template match="*"/>
</xsl:stylesheet>
\ No newline at end of file
</xsl:stylesheet>
......@@ -6,12 +6,12 @@
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="c:container">
<project name="getContentFileAndTransformIt" basedir=".." default="start">
<project name="getContentFileAndTransformIt" basedir="." default="start">
<property file="global.properties"/>
<property name="filename" location="${filename}"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath>
<pathelement location="./lib/jing.jar"/>
<pathelement location="../lib/jing.jar"/>
</classpath>
</taskdef>
......@@ -21,31 +21,35 @@
<xsl:template match="c:rootfiles">
<target name="start">
<jing file="${{tmp}}/decompressedHdoc/{c:rootfile/@full-path}" rngfile="${{schema}}/hdoc1-xhtml.rng"></jing>
<jing file="${{tmp}}/${{filename}}/decompressedHdoc/{c:rootfile/@full-path}" rngfile="${{schema}}/hdoc1-xhtml.rng"></jing>
<xslt
in="${{tmp}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/moveRessourceFiles.xml"
in="${{tmp}}/${{filename}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/${{filename}}/moveRessourceFiles.xml"
style="${{xsl}}/moveRessourceFiles.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<chmod file="${{tmp}}/moveRessourceFiles.xml" perm="777"/>
>
<param name="filename" expression="${{tmp}}/${{filename}}"/>
</xslt>
<chmod file="${{tmp}}/${{filename}}/moveRessourceFiles.xml" perm="777"/>
<xslt
in="${{tmp}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/decompressedOpale/main.xml"
in="${{tmp}}/${{filename}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/${{filename}}/decompressedOpale/main.xml"
style="${{xsl}}/transformation2.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<chmod file="${{tmp}}/decompressedOpale/main.xml" perm="777"/>
<chmod file="${{tmp}}/${{filename}}/decompressedOpale/main.xml" perm="777"/>
<!-- Finding references and converting them -->
<xslt
in="${{tmp}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/convertReferences.xml"
in="${{tmp}}/${{filename}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/${{filename}}/convertReferences.xml"
style="${{xsl}}/prepareReferencesConversions.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
/>
<ant antfile="${{tmp}}/convertReferences.xml"/>
>
<param name="filename" expression="${{tmp}}/${{filename}}"/>
</xslt>
<ant antfile="${{tmp}}/${{filename}}/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