Commit 8197c7b7 authored by lhommeni's avatar lhommeni

Merge branch 'master' of https://gitlab.utc.fr/crozatst/hdoc

parents 67d3f797 230f112f
<?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>
<?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"
xmlns:sc="http://www.utc.fr/ics/scenari/v3/core"
xmlns:op="utc.fr:ics/opale3"
xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive"
>
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<!-- This template matches the root. One hdoc file = one Opale's "Module" -->
<xsl:template match="h:html">
<sc:item xmlns:sc="http://www.utc.fr/ics/scenari/v3/core">
<op:ue xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive" xmlns:op="utc.fr:ics/opale3" xmlns:sc="http://www.utc.fr/ics/scenari/v3/core">
<xsl:apply-templates select="./*"/>
</op:ue>
</sc:item>
</xsl:template>
<!-- Head related templates. -->
<xsl:template match="h:head">
<op:ueM xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive" xmlns:op="utc.fr:ics/opale3" xmlns:sc="http://www.utc.fr/ics/scenari/v3/core">
<sp:title>
<xsl:value-of select="./h:title"/>
</sp:title>
<sp:info>
<op:info>
<xsl:apply-templates select="./h:meta"/>
<!-- Author: in case several authors are specified, we don't want to get an error for not respecting the schema -->
<xsl:if test="./h:meta[@name='author']">
<sp:cpyrgt>
<op:sPara>
<sc:para>
<xsl:call-template name="join">
<xsl:with-param name="list" select="./h:meta[@name='author']/@content" />
<xsl:with-param name="separator" select="', '" />
</xsl:call-template>
</sc:para>
</op:sPara>
</sp:cpyrgt>
</xsl:if>
</op:info>
</sp:info>
</op:ueM>
</xsl:template>
<!-- Join template found at http://stackoverflow.com/questions/12585974/xslt-merging-concatinating-values-of-siblings-nodes-of-same-name-into-single-nod -->
<xsl:template name="join">
<xsl:param name="list" />
<xsl:param name="separator"/>
<xsl:for-each select="$list">
<xsl:value-of select="." />
<xsl:if test="position() != last()">
<xsl:value-of select="$separator" />
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="h:meta[@name]">
<xsl:choose>
<xsl:when test="./@name = 'description'"/> <!-- Unsupported : Opale doesn't provide any description metadata. -->
<xsl:when test="./@name = 'keywords'"> <!-- This is the least to do, since there's no specific format for keywords in hdoc. -->
<sp:keywds>
<op:keywds>
<sp:keywd><xsl:value-of select="./@content"/></sp:keywd>
</op:keywds>
</sp:keywds>
</xsl:when>
<xsl:when test="./@name = 'author'"/> <!-- Done above -->
<xsl:when test="./@name = 'rights'">
<xsl:choose>
<xsl:when test="./@content = 'http://creativecommons.org/publicdomain/zero/1.0/deed.en'"><sp:cc>zero</sp:cc></xsl:when>
<xsl:when test="./@content = 'Public Domain'"><sp:cc>publicdomain</sp:cc></xsl:when>
<xsl:when test="./@content = 'http://www.gnu.org/licenses/gpl.html'"><sp:cc>gnu-fdl</sp:cc></xsl:when>
<xsl:when test="./@content = 'http://creativecommons.org/licenses/by/4.0/deed.en'"><sp:cc>by</sp:cc></xsl:when>
<xsl:when test="./@content = 'http://creativecommons.org/licenses/by-sa/4.0/deed.en'"><sp:cc>by-sa</sp:cc></xsl:when>
<xsl:when test="./@content = 'http://creativecommons.org/licenses/by-nd/4.0/deed.en'"><sp:cc>by-nd</sp:cc></xsl:when>
<xsl:when test="./@content = 'http://creativecommons.org/licenses/by-nc/4.0/deed.en'"><sp:cc>by-nc</sp:cc></xsl:when>
<xsl:when test="./@content = 'http://creativecommons.org/licenses/by-nc-sa/4.0/deed.en'"><sp:cc>by-nc-sa</sp:cc></xsl:when>
<xsl:when test="./@content = 'http://creativecommons.org/licenses/by-nc-nd/4.0/deed.en'"><sp:cc>by-nc-nd</sp:cc></xsl:when>
<xsl:otherwise/> <!-- This previous list is supposed to support every possible case, any other value for "rights" are unsupported. -->
</xsl:choose>
</xsl:when>
<xsl:when test="./@name = 'date'"/> <!-- Unsupported : Opale doesn't provide any date metadata. -->
<xsl:otherwise/> <!-- There are no other values for ./@name right now. -->
</xsl:choose>
</xsl:template>
<!-- Body related templates. -->
<xsl:template match="h:body">
<xsl:if test="./h:section[@data-hdoc-type = 'introduction']/h:div/*">
<sp:intro>
<op:res>
<xsl:apply-templates select="./h:section[@data-hdoc-type = 'introduction']/h:div/*" />
</op:res>
</sp:intro>
</xsl:if>
<!-- In case an introduction contains subsections, we consider them as regular sections outside from it -->
<xsl:apply-templates select="./h:section[@data-hdoc-type = 'introduction']/h:section"/>
<!-- Not selecting introductions or conclusions -->
<xsl:apply-templates select="./h:section[not(@data-hdoc-type = 'introduction' or @data-hdoc-type = 'conclusion')]"/>
<!-- Same thing as for the introduction -->
<xsl:apply-templates select="./h:section[@data-hdoc-type = 'conclusion']/h:section"/>
<xsl:if test="./h:section[@data-hdoc-type = 'conclusion']/h:div/*">
<sp:conclu>
<op:res>
<xsl:apply-templates select="./h:section[@data-hdoc-type = 'conclusion']/h:div/*" />
</op:res>
</sp:conclu>
</xsl:if>
</xsl:template>
<!-- Introduction <section> -->
<xsl:template match="h:div[@data-hdoc-type='introduction']">
<sp:intro>
<op:res>
<xsl:apply-templates select="./h:p" />
</op:res>
</sp:intro>
</xsl:template>
<!-- Conclusion <section> -->
<xsl:template match="h:div[@data-hdoc-type='conclusion']">
<sp:conclu>
<op:res>
<!-- Going straight to the content -->
<!-- For the conclusion, we ignore <header> and <footer> -->
<xsl:apply-templates select="./h:p" />
</op:res>
</sp:conclu>
</xsl:template>
<!-- Grains <sections>. A grain is either a unit-of-content, or does not contain sub divisions (<section>'s) -->
<xsl:template match="h:section[@data-hdoc-type='unit-of-content' or h:div or not(h:section)]">
<sp:courseUc>
<op:expUc>
<op:uM>
<sp:title>
<!-- Adding a default value for titles (Opale requires a title to be specified) -->
<xsl:if test="not(./h:header/h:h1/text())">
Untitled
</xsl:if>
<xsl:value-of select="./h:header/h:h1"/>
</sp:title>
</op:uM>
<!-- TODO test level of sub division (section/section/section) -->
<xsl:if test="./h:div">
<sp:pb>
<op:pb>
<xsl:apply-templates select="./h:div"/>
</op:pb>
</sp:pb>
</xsl:if>
<!-- Applying sub sections -->
<xsl:apply-templates select="./h:section" mode="under-unit-of-content" />
</op:expUc>
</sp:courseUc>
</xsl:template>
<xsl:template match="h:section" mode="under-unit-of-content">
<sp:div>
<op:expUcDiv>
<op:expUcDivM>
<sp:title>
<!-- Adding a default value for titles (Opale requires a title to be specified) -->
<xsl:if test="not(./h:header/h:h1/text())">
Untitled
</xsl:if>
<xsl:value-of select="./h:header/h:h1"/>
</sp:title>
</op:expUcDivM>
<!-- TODO test level of sub division (section/section/section) -->
<xsl:if test="./h:div">
<sp:pb>
<op:pb>
<xsl:apply-templates select="./h:div"/>
</op:pb>
</sp:pb>
</xsl:if>
<xsl:apply-templates select="./h:section" mode="under-unit-of-content" />
</op:expUcDiv>
</sp:div>
</xsl:template>
<!-- Basic <section> (nothing was specified) -->
<xsl:template match="h:section">
<!-- Every section is converted into what Opale calls a "Division" -->
<!-- For now there are no specific processes applied on sections with an "introduction" or "conclusion" value in their data-hdoc-type attribute.
They are processed the same as standard sections.
-->
<sp:div>
<op:ueDiv>
<op:ueDivM>
<sp:title>
<xsl:value-of select="./h:header/h:h1"/>
</sp:title>
</op:ueDivM>
<!-- Intro for a division -->
<xsl:apply-templates select="./h:header/h:div[@data-hdoc-type='introduction']" />
<!-- Taking care of the content. If content exists, we add it as a "grain" (we also add a title to it) -->
<xsl:if test="./h:div">
<sp:courseUc>
<op:expUc>
<op:uM>
<xsl:if test="./h:header/h:h1">
<sp:title>
<xsl:value-of select="./h:header/h:h1"/>
</sp:title>
</xsl:if>
</op:uM>
<xsl:if test="./h:div">
<sp:pb>
<op:pb>
<xsl:apply-templates select="./h:div"/>
</op:pb>
</sp:pb>
</xsl:if>
</op:expUc>
</sp:courseUc>
</xsl:if>
<!-- Applying templates to section that are neither an introduction nor a conclusion -->
<xsl:apply-templates select="./h:section[not(@data-hdoc-type = 'introduction' or @data-hdoc-type = 'conclusion')]"/>
<!-- Conclusion for a division -->
<xsl:apply-templates select="./h:header/h:div[@data-hdoc-type='conclusion']" />
</op:ueDiv>
</sp:div>