Commit d11314b2 authored by Decorde Jeffrey's avatar Decorde Jeffrey
Browse files

Several input files handled

parent 0995aa24
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<property file="global.properties"/> <property file="global.properties"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask"> <taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath> <classpath>
<pathelement location="lib/jing.jar"/> <pathelement location="lib/jing.jar"/>
...@@ -26,7 +27,19 @@ ...@@ -26,7 +27,19 @@
<antcall target="ValidateInput" /> <antcall target="ValidateInput" />
<antcall target="FindContentFiles"/> <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="ValidateOutput"/>
<antcall target="DivideOutput"/> <antcall target="DivideOutput"/>
...@@ -34,13 +47,12 @@ ...@@ -34,13 +47,12 @@
<antcall target="ZipOutput"/> <antcall target="ZipOutput"/>
<antcall target="ZipDividedOutput"/> <antcall target="ZipDividedOutput"/>
<antcall target="CleanDirectory"/>
</target> </target>
<target name="CleanDirectory"> <target name="CleanDirectory">
<delete> <delete>
<fileset dir="${tmp}"> <fileset dir="${tmp}">
<include name="**/*"/> <include name="*"/>
</fileset> </fileset>
</delete> </delete>
</target> </target>
...@@ -48,80 +60,143 @@ ...@@ -48,80 +60,143 @@
<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
refers to the hdoc file furthermore in this project. --> refers to the hdoc file furthermore in this project. -->
<unzip dest="${tmp}/decompressedHdoc"> <for param="inputFile">
<fileset dir="${in}"> <path>
<include name="**/*.hdoc"/> <fileset dir="${in}" includes="**/*.hdoc"/>
</fileset> </path>
</unzip> <sequential>
<chmod dir="${tmp}/decompressedHdoc" perm="777"/> <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>
<target name="FindContentFiles"> <target name="FindContentFiles">
<!-- Finds the absolute path of container.xml and applies transformation0.xsl on it.--> <!-- Finds the absolute path of container.xml and applies transformation0.xsl on it.-->
<first id="first"> <for param="inputFile">
<fileset dir="${tmp}/decompressedHdoc/META-INF" includes="**/container.xml"/> <path>
</first> <fileset dir="${in}" includes="**/*.hdoc"/>
<xslt in="${toString:first}" out="${tmp}/generateContentPath.xml" style="${xsl}/transformation0.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison" /> </path>
<chmod file="${tmp}/generateContentPath.xml" perm="777"/> <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>
<target name="ZipOutput"> <target name="ZipOutput">
<copy file="${bibtex}/.wspmeta" todir="${tmp}/decompressedOpale"/> <for param="inputFile">
<mkdir dir="${tmp}/decompressedOpale/res"/> <path>
<ant antfile="${tmp}/moveRessourceFiles.xml"/> <fileset dir="${in}" includes="**/*.hdoc"/>
<zip basedir="${tmp}/decompressedOpale" destfile="${out}/output.scar" encoding="UTF-8"/> </path>
</target> <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"> <target name="ZipDividedOutput">
<copy file="${bibtex}/.wspmeta" todir="${tmp}/decompressedOpaleDivided"/> <for param="inputFile">
<copy todir="${tmp}/decompressedOpaleDivided/res" > <path>
<fileset dir="${tmp}/decompressedOpale/res" includes="**"/> <fileset dir="${in}" includes="**/*.hdoc"/>
</copy> </path>
<copy todir="${tmp}/decompressedOpaleDivided/references" > <sequential>
<fileset dir="${tmp}/decompressedOpale/references" includes="**"/> <local name="filename"/>
</copy> <basename property="filename" file="@{inputFile}"/>
<zip basedir="${tmp}/decompressedOpaleDivided" destfile="${out}/outdividedOutput.scar" encoding="UTF-8"/> <copy file="${bibtex}/.wspmeta" todir="${tmp}/${filename}/decompressedOpaleDivided"/>
</target> <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 --> <!-- Validating the XML container file -->
<target name="ValidateInput"> <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> </target>
<!-- Validating the XML output --> <!-- Validating the XML output -->
<target name="ValidateOutput"> <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>
<target name="DivideOutput"> <target name="DivideOutput">
<mkdir dir="${tmp}/decompressedOpaleDivided"/> <for param="inputFile">
<path>
<!-- Adding IDS to the general output file --> <fileset dir="${in}" includes="**/*.hdoc"/>
<xslt </path>
in="${tmp}/decompressedOpale/main.xml" <sequential>
out="${tmp}/outputWithCourseUcIds.xml" <local name="filename"/>
style="${xsl}/addCourseUcIds.xsl" <basename property="filename" file="@{inputFile}"/>
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison" <mkdir dir="${tmp}/${filename}/decompressedOpaleDivided"/>
/>
<!-- Adding IDS to the general output file -->
<!-- Generating the root file (with refs to other files) --> <xslt
<xslt in="${tmp}/${filename}/decompressedOpale/main.xml"
in="${tmp}/outputWithCourseUcIds.xml" out="${tmp}/${filename}/outputWithCourseUcIds.xml"
out="${tmp}/decompressedOpaleDivided/main.xml" style="${xsl}/addCourseUcIds.xsl"
style="${xsl}/addCourseUcReferences.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison" />
/>
<!-- Generating the root file (with refs to other files) -->
<!-- Generating the ANT file that will copy the files --> <xslt
<xslt in="${tmp}/${filename}/outputWithCourseUcIds.xml"
in="${tmp}/outputWithCourseUcIds.xml" out="${tmp}/${filename}/decompressedOpaleDivided/main.xml"
out="${tmp}/exportUnits.ant" style="${xsl}/addCourseUcReferences.xsl"
style="${xsl}/prepareCourseUcCopies.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison" />
/>
<!-- Generating the ANT file that will copy the files -->
<!-- Executing that ANT file --> <xslt
<ant antfile="${tmp}/exportUnits.ant"/> 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> </target>
</project> </project>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<xsl:template match="h:html"> <xsl:template match="h:html">
<project name="moveRessourceFiles" basedir="." default="moveRessourceFiles"> <project name="moveRessourceFiles" basedir="." default="moveRessourceFiles">
<property file="global.properties"/> <property file="global.properties"/>
<property name="filename" location="${filename}"/>
<target name="moveRessourceFiles"> <target name="moveRessourceFiles">
<xsl:apply-templates select="./*"/> <xsl:apply-templates select="./*"/>
</target> </target>
...@@ -30,16 +30,16 @@ ...@@ -30,16 +30,16 @@
<!-- Targeted markups. --> <!-- Targeted markups. -->
<xsl:template match="h:img"> <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>
<xsl:template match="h:audio"> <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>
<xsl:template match="h:video"> <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>
<xsl:template match="h:object"> <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> </xsl:template>
<!-- These markups are matched in order to minimize "apply-templates" side-effects (i.e. their contents are not relevant for this transformation). --> <!-- 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 @@ ...@@ -7,9 +7,10 @@
xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive" xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive"
> >
<xsl:output method="xml" indent="yes" encoding="UTF-8"/> <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:param name="filename"/>
<xsl:template match="sc:item"> <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="in" location="${{basedir}}/input"/>
<property name="out" location="${{basedir}}/output"/> <property name="out" location="${{basedir}}/output"/>
<property name="tmp" location="${{basedir}}/tmp"/> <property name="tmp" location="${{basedir}}/tmp"/>
...@@ -17,9 +18,10 @@ ...@@ -17,9 +18,10 @@
<property name="lib" location="${{basedir}}/lib"/> <property name="lib" location="${{basedir}}/lib"/>
<property name="log" location="${{basedir}}/log"/> <property name="log" location="${{basedir}}/log"/>
<property name="schema" location="${{basedir}}/schema"/> <property name="schema" location="${{basedir}}/schema"/>
<property name="filename" location="${{tmp}}/{$filename}"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask"> <taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath> <classpath>
<pathelement location="./lib/jing.jar"/> <pathelement location="../lib/jing.jar"/>
</classpath> </classpath>
</taskdef> </taskdef>
...@@ -33,16 +35,15 @@ ...@@ -33,16 +35,15 @@
<xsl:template match="sp:courseUc"> <xsl:template match="sp:courseUc">
<xslt <xslt
in="${{tmp}}/outputWithCourseUcIds.xml" in="${{filename}}/outputWithCourseUcIds.xml"
out="${{tmp}}/decompressedOpaleDivided/{@data-export-file}" out="${{filename}}/decompressedOpaleDivided/{@data-export-file}"
style="${{xsl}}/copyCourseUc.xsl" style="${{xsl}}/copyCourseUc.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison"
> >
<param name="elementid" expression="{@data-export-id}"/> <param name="elementid" expression="{@data-export-id}"/>
</xslt> </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:template>
</xsl:stylesheet> </xsl:stylesheet>
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
<xsl:template match="h:html"> <xsl:template match="h:html">
<project name="copy-references" default="main"> <project name="copy-references" default="main">
<property file="global.properties"/> <property file="global.properties"/>
<property name="filename" location="${filename}"/>
<target name="main"> <target name="main">
<mkdir dir="${{tmpdir}}/decompressedOpale/references" /> <mkdir dir="${{tmp}}/${{filename}}/decompressedOpale/references" />
<xsl:apply-templates select=".//h:a[@data-hdoc-type = 'bibtexml']"/> <xsl:apply-templates select=".//h:a[@data-hdoc-type = 'bibtexml']"/>
</target> </target>
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<xsl:template match="h:a[@data-hdoc-type = 'bibtexml']"> <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) --> <!-- 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) --> <!-- 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"> <ant antfile="${{basedir}}/bibtex_to_opale/Ant/bibtex_to_opale.ant" target="convertfrombibxml">
...@@ -32,17 +32,17 @@ ...@@ -32,17 +32,17 @@
</ant> </ant>
<!-- Creating the directory to unzip to --> <!-- 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 --> <!-- 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) --> <!-- 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 --> <!-- 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>
<xsl:template match="*"/> <xsl:template match="*"/>
</xsl:stylesheet> </xsl:stylesheet>
\ No newline at end of file
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<xsl:output method="xml" indent="yes" encoding="UTF-8"/> <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="c:container"> <xsl:template match="c:container">
<project name="getContentFileAndTransformIt" basedir=".." default="start"> <project name="getContentFileAndTransformIt" basedir="." default="start">
<property file="global.properties"/> <property file="global.properties"/>
<property name="filename" location="${filename}"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask"> <taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath> <classpath>
<pathelement location="./lib/jing.jar"/> <pathelement location="../lib/jing.jar"/>
</classpath> </classpath>
</taskdef> </taskdef>
...@@ -21,31 +21,35 @@ ...@@ -21,31 +21,35 @@
<xsl:template match="c:rootfiles"> <xsl:template match="c:rootfiles">
<target name="start"> <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 <xslt
in="${{tmp}}/decompressedHdoc/{c:rootfile/@full-path}" in="${{tmp}}/${{filename}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/moveRessourceFiles.xml" out="${{tmp}}/${{filename}}/moveRessourceFiles.xml"
style="${{xsl}}/moveRessourceFiles.xsl" style="${{xsl}}/moveRessourceFiles.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison" 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 <xslt
in="${{tmp}}/decompressedHdoc/{c:rootfile/@full-path}" in="${{tmp}}/${{filename}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/decompressedOpale/main.xml" out="${{tmp}}/${{filename}}/decompressedOpale/main.xml"
style="${{xsl}}/transformation2.xsl" style="${{xsl}}/transformation2.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison" 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 --> <!-- Finding references and converting them -->
<xslt <xslt
in="${{tmp}}/decompressedHdoc/{c:rootfile/@full-path}" in="${{tmp}}/${{filename}}/decompressedHdoc/{c:rootfile/@full-path}"
out="${{tmp}}/convertReferences.xml" out="${{tmp}}/${{filename}}/convertReferences.xml"
style="${{xsl}}/prepareReferencesConversions.xsl" style="${{xsl}}/prepareReferencesConversions.xsl"
processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison" 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> </target>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
Supports Markdown
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