Commit 794dc845 authored by Ivan D'halluin's avatar Ivan D'halluin
Browse files

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

parents 9c772450 f00cf78f
#!/bin/sh
lib="lib"
ant="mindmapping_to_opale.ant"
antparam="-Dprogram.param=$1"
inputPath="$2"
#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/*"
if [ "$inputPath" == '' ] ; then
echo "Appel sans paramètre"
$vJavaCmd -classpath "$scJarList:" -Xmx150m org.apache.tools.ant.Main -buildfile $ant $antparam
else
echo "Appel avec paramètre"
$vJavaCmd -classpath "$scJarList:" -Xmx150m org.apache.tools.ant.Main -buildfile $ant $antparam -DinputPath $inputPath
fi
\ No newline at end of file
......@@ -15,21 +15,17 @@
<!-- Beginning -->
<target name="convert">
<antcall target="clean" />
<antcall target="unzip_scar" />
<antcall target="check_source_xml" />
<antcall target="hdoc_structure" />
<antcall target="fusion_xml" />
<antcall target="content_xml" />
<antcall target="zip" />
<antcall target="clean" />
</target>
<!-- Clean : delete old files -->
<target name="clean">
<!-- create folders (to be sure) -->
<mkdir dir="${UnzipSourcePath}"/>
<mkdir dir="${TmpPath}"/>
<mkdir dir="${HdocPath}"/>
<!-- delete folders -->
<delete dir="${UnzipSourcePath}"/>
<delete dir="${TmpPath}"/>
......@@ -76,7 +72,7 @@
<echoxml file="${HdocPath}/META-INF/container.xml" namespacePolicy="elementsOnly">
<container xmlns="urn:utc.fr:ics:hdoc:container" version="1.0">
<rootfiles>
<rootfile full-path="${HdocPath}/${RacineFile}" media-type="text/xml" />
<rootfile full-path="${RacineFile}" media-type="text/xml" />
</rootfiles>
</container>
</echoxml>
......
......@@ -12,12 +12,16 @@
xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive"
xmlns:op="utc.fr:ics/opale3">
<xsl:template match="sc:item">
<xsl:apply-templates/>
</xsl:template>
<!-- MODULE -->
<xsl:template match="op:ue">
<!-- RNG -->
<xsl:processing-instruction name="oxygen">
RNGSchema="http://scenari.utc.fr/hdoc/schemas/xhtml/hdoc1-xhtml.rng" type="xml"
RNGSchema="http://hdoc.crzt.fr/schemas/xhtml/hdoc1-xhtml.rng" type="xml"
</xsl:processing-instruction>
<!-- HTML -->
......@@ -27,7 +31,7 @@
<head>
<xsl:apply-templates select="op:ueM/sp:title"/>
<meta charset="utf-8"/>
<meta generator="HdocConverter/Opale3.4"/>
<meta content="HdocConverter/Opale3.4" name="generator"/>
<xsl:apply-templates select="op:ueM/sp:info"/>
</head>
......@@ -109,7 +113,11 @@
</header>
<!-- currently : grain & introduction & conclusion -->
<xsl:apply-templates select="./op:courseUa/child::*[name() != 'op:uM'][name() != 'sp:quest']"/>
<!-- <xsl:apply-templates select="./op:courseUa/child::*[name() != 'op:uM'][name() != 'sp:quest']"/>-->
<xsl:apply-templates select="./op:courseUa/sp:courseUc"/>
<xsl:apply-templates select="./op:courseUa/sp:intro"/>
<xsl:apply-templates select="./op:courseUa/sp:conclu"/>
<xsl:apply-templates select="./op:courseUa/sp:obj"/>
<!-- overview questions : regroup questions into a section-->
<xsl:if test="./op:courseUa/sp:quest">
......@@ -140,7 +148,8 @@
</header>
<!-- call for blocs and parts -->
<xsl:apply-templates select="./op:expUc/child::*[name() != 'op:uM']"/>
<!-- <xsl:apply-templates select="./op:expUc/child::*[name() != 'op:uM']"/>-->
<xsl:apply-templates select="./op:expUc/sp:pb/op:pb/*"/>
<footer>
<xsl:apply-templates select="./op:expUc/op:uM/sp:info/op:info/sp:keywds"/>
......@@ -148,6 +157,18 @@
</section>
</xsl:template>
<!-- Aims (aims don't have metadata) -->
<xsl:template match="sp:obj">
<section>
<header>
<h1>Objectifs</h1>
</header>
<div>
<xsl:apply-templates select="./op:sTxt/*"/>
</div>
</section>
</xsl:template>
<!-- Introduction (a introduction doesn't have metadata) -->
<xsl:template match="sp:intro">
<section data-hdoc-type="introduction">
......@@ -174,6 +195,12 @@
</section>
</xsl:template>
<xsl:template match="sp:filtered">
<xsl:if test="op:filter/sp:exclude/text() = 'short'">
<xsl:apply-templates select="./op:res/*"/>
</xsl:if>
</xsl:template>
<!-- Overview questions (fr : question de synthèse) -->
<xsl:template match="sp:quest">
<xsl:apply-templates select="./op:txt/*"/>
......@@ -419,4 +446,12 @@
<!-- ***** TEXT END ***** -->
<xsl:template match="op:res/sp:listing">
<p>
<xsl:value-of select="./op:code/sc:code"></xsl:value-of>
</p>
</xsl:template>
<xsl:template match="*"></xsl:template>
</xsl:stylesheet>
Pour réaliser votre conversion vous devez ajouter votre fichier .scar dans le dossier input.
Veillez à n'en placer qu'un seul dedans.
Ensuite il suffit d'appeler le script (.bat ou .sh).
!!Attention!! Ce script efface tous les input et output préalablement contenus dans les deux conversions.
\ No newline at end of file
<project name="ProjetOpale" default="convert">
<!-- Beginning -->
<target name="convert">
<antcall target="clean_everything" />
<antcall target="opale_to_hdoc" />
<antcall target="hdoc_to_optim" />
<antcall target="copy_optim_output" />
</target>
<target name="clean_everything">
<delete dir="../opale_to_hdoc/input"/>
<delete dir="../opale_to_hdoc/output/result.hdoc"/>
<delete dir="../hdoc_to_optim/input"/>
<delete dir="../hdoc_to_optim/output/result.scar"/>
</target>
<target name="opale_to_hdoc">
<copy tofile="../opale_to_hdoc/input/sample.scar" file="input/sample.scar"/>
<ant antfile="../opale_to_hdoc/opale_to_hdoc.ant" inheritAll="false"/>
</target>
<target name="hdoc_to_optim">
<copy tofile="../hdoc_to_optim/input/sample.hdoc" file="../opale_to_hdoc/output/result.hdoc"/>
<ant antfile="../hdoc_to_optim/hdoc_to_optim.ant" inheritAll="false"/>
</target>
<target name="copy_optim_output">
<copy tofile="output/result.scar" file="../hdoc_to_optim/output/result.scar"/>
</target>
</project>
\ No newline at end of file
@echo off
set lib=lib
set ant=myantce.ant
set ant=opale_to_optim.ant
set antparam=-Dprogram.param=%1
set scJarList=%lib%\*
......
#!/bin/sh
lib="lib"
ant="myantce.ant"
ant="opale_to_optim.ant"
antparam="-Dprogram.param=$1"
#Recherche de java et controle que se soit une version SUN
......
......@@ -8,10 +8,11 @@
<property name="log" location="${basedir}/log"/>
<property name="optim_to_hdoc" location="${basedir}/../optim_to_hdoc"/>
<property name="hdoc_to_opale" location="${basedir}/../hdoc_to_opale"/>
<property name="optim_to_hdoc_in" location="${basedir}/../optim_to_hdoc/input"/>
<property name="hdoc_to_opale_in" location="${basedir}/../hdoc_to_opale/input"/>
<property name="optim_to_hdoc_out" location="${basedir}/../optim_to_hdoc/output"/>
<property name="hdoc_to_opale_out" location="${basedir}/../hdoc_to_opale/output"/>
<property name="optim_to_hdoc_in" location="${optim_to_hdoc}/input"/>
<property name="hdoc_to_opale_in" location="${hdoc_to_opale}/input"/>
<property name="optim_to_hdoc_out" location="${optim_to_hdoc}/output"/>
<property name="hdoc_to_opale_out" location="${hdoc_to_opale}/output"/>
<property name="optim_to_hdoc_ant" location="${optim_to_hdoc}/optim_to_hdoc.ant"/>
<!-- Mandatory ressource to use if conditions -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
......@@ -21,10 +22,22 @@
</taskdef>
<!-- CHECK FOR FAMILY OS -->
<condition property="is_windows">
<os family="windows"/>
</condition>
<condition property="is_unix">
<os family="unix"/>
</condition>
<!-- Main target -->
<target name="main">
<antcall target="clean"/>
<!-- Check that the input directory is not empty -->
<if>
<length length="0" when="greater">
<fileset dir="${in}" followsymlinks="false"/>
......@@ -40,6 +53,7 @@
<antcall target="prepare_hdoc_to_opale"/>
<antcall target="run_hdoc_to_opale"/>
<antcall target="output_files"/>
</then>
<else>
......@@ -53,6 +67,8 @@
<!-- optim_to_hdoc -->
<!-- Moves files in optim_to_hdoc hierarchy -->
<target name="prepare_optim_to_hdoc">
<antcall target="add_log">
......@@ -60,15 +76,46 @@
</antcall>
<copy todir="${optim_to_hdoc_in}">
<fileset dir="${in}"/>
<fileset dir="${in}">
<include name="*.scar"/>
</fileset>
</copy>
</target>
<!-- Simply run optim_to_hdoc script -->
<target name="run_optim_to_hdoc">
<antcall target="run_optim_to_hdoc_unix"/>
<antcall target="run_optim_to_hdoc_windows"/>
</target>
<!-- Run optim_to_hdoc bat -->
<target name="run_optim_to_hdoc_windows" if="${is_windows}">
<antcall target="add_log">
<param name="msg" value="Running optim_to_hdoc bat script"/>
</antcall>
<exec executable="cmd" dir="${optim_to_hdoc}">
<arg value="/c"/>
<arg value="${optim_to_hdoc}/run.bat"/>
</exec>
</target>
<!-- Run optim_to_hdoc sh -->
<target name="run_optim_to_hdoc_unix" if="${is_unix}">
<antcall target="add_log">
<param name="msg" value="Running optim_to_hdoc shell script"/>
</antcall>
<exec executable="/bin/bash" dir="${optim_to_hdoc}">
<arg value="${optim_to_hdoc}/run.sh"/>
</exec>
</target>
<!-- hdoc_to_opale -->
<!-- Moves files in hdoc_to_opale hierarchy -->
<target name="prepare_hdoc_to_opale">
<antcall target="add_log">
......@@ -76,12 +123,40 @@
</antcall>
<copy todir="${hdoc_to_opale_in}">
<fileset dir="${optim_to_hdoc_out}"/>
<fileset dir="${optim_to_hdoc_out}">
<include name="*.hdoc"/>
</fileset>
</copy>
</target>
<!-- Simply run hdoc_to_opale script -->
<target name="run_hdoc_to_opale"></target>
<target name="run_hdoc_to_opale">
<antcall target="run_hdoc_to_opale_unix"/>
<antcall target="run_hdoc_to_opale_windows"/>
</target>
<!-- Run hdoc_to_opale bat -->
<target name="run_hdoc_to_opale_windows" if="${is_windows}">
<antcall target="add_log">
<param name="msg" value="Running hdoc_to_opale bat script"/>
</antcall>
<exec executable="cmd" dir="${hdoc_to_opale}">
<arg value="/c"/>
<arg value="${hdoc_to_opale}/run.bat"/>
</exec>
</target>
<!-- Run hdoc_to_opale sh -->
<target name="run_hdoc_to_opale_unix" if="${is_unix}">
<antcall target="add_log">
<param name="msg" value="Running hdoc_to_opale shell script"/>
</antcall>
<exec executable="/bin/bash" dir="${hdoc_to_opale}">
<arg value="${hdoc_to_opale}/run.sh"/>
</exec>
</target>
<!-- Move files to the outut directory -->
<target name="output_files">
......@@ -95,6 +170,12 @@
</target>
<!-- Some basic functions -->
<!-- Print a line both on screen and in log/execution.log file -->
<target name="add_log">
<tstamp>
<format property="now" pattern="HH:mm:ss:sss" locale="fr,FR"/>
......@@ -104,7 +185,7 @@
<echo message="${msg}"/>
</target>
<!-- Cleaning directories -->
<target name="clean">
<delete dir="${log}" failonerror="false"/>
<mkdir dir="${log}"/>
......
Optim to Opale (optim_to_opale)
-------------------------------
Last edit: December 17, 2015
# Purpose
`optim_to_opale` is an ANT script to convert a file from Optim format to Opale format.
# Dependencies
In order to work properly this script needs
1. `optim_to_hdoc` (Optim to HDoc conversion)
2. `hdoc_to_opale` (HDoc to Opale conversion)
# Running the script
1. Put the file you want to convert into the `input` directory
2. Run the `run.sh`file on a Unix system (Linux, Mac OS, etc.) or the `run.bat`on Windows
3. Your converted file is placed into the `output` directory (a log file is also placed into the `log`directory)
4. Enjoy!
# How is this script working
1. The script first determines what OS you are using so it then can call the right scripts
2. It cleans the `log`, `tmp`and `output`directories
3. It copies the files that are inside the `input`directory to the `input` directory of `optim_to_hdoc`
4. It calls `optim_to_hdoc`run script (`.bat` on windows, `.sh`on Unix)
5. It copies the files that are inside the `output`directory of `optim_to_hdoc` to the `input` directory of `hdoc_to_opale`
6. It calls `hdoc_to_opale`run script (`.bat` on windows, `.sh`on Unix)
7. It copies the files that are inside the `output`directory of `hdoc_to_opale` to the `output` directory of `optim_to_opale`
During all the process it also prints some basic information both on screen and in the log file.
@echo off
set lib=lib
set ant=myantce.ant
set ant=optim_to_opale.ant
set antparam=-Dprogram.param=%1
set scJarList=%lib%\*
......
#!/bin/sh
lib="lib"
ant="myantce.ant"
ant="optim_to_opale.ant"
antparam="-Dprogram.param=$1"
#Recherche de java et controle que se soit une version SUN
......
!input/**
result/**
tmp/**
\ No newline at end of file
Getting started
---------------
Use a terminal and go to the root of the folder (Wikipedia_to_hdoc).
Generating .hdoc of a Wikipedia article with an URL
---------------------------------------------------
1 - Run the comand corresponding to your OS
On windows :
runURL.bat yourWikipediaUrl yourFilename
yourWikipediaUrl is the Wikipedia URL
yourFilename is the name of the directory in which output files will be placed
For instance : runURL.bat https://fr.wikipedia.org/wiki/Constructeur_(programmation) constructeur
On Linux :
sh runURL.sh yourWikipediaUrl yourFilename
yourWikipediaUrl is the Wikipedia URL
yourFilename is the name of the directory in which output files will be placed
For instance : sh runURL.sh https://fr.wikipedia.org/wiki/Constructeur_(programmation) constructeur
2 - Get the .hdoc in the output/yourFilename folder
Generating .hdoc of a Wikipedia article with a local file
---------------------------------------------------------
1 - Copy the content of the Wikipedia article you want to convert in the directory named “input” and in a file called “source.xml".
2 - Run the comand corresponding to your OS
On windows :
runFile.bat
On Linux :
sh runFile.sh
3 - Get the .hdoc in the output/source folder
\ No newline at end of file
......@@ -4,7 +4,7 @@
<!-- input path -->
<property name="in" value="${basedir}/input"/>
<!-- inputFile is the only required parameter to run the script -->
<property name="inputFile" value="${inputFile}/source.xml"/>
<property name="inputFile" value="${in}/source.xml"/>
<basename property="filename" file="${inputFile}" suffix=".xml"/>
......@@ -20,11 +20,11 @@
<!-- Main target -->
<target name="main">
<antcall target="clean"/>
<antcall target="prepare"/>
<antcall target="prepareHdocStructure"/>
<antcall target="transformWikiToHdoc"/>
<antcall target="zip"/>
<antcall target="clean"/>
</target>
<target name="prepare">
......@@ -33,7 +33,7 @@
<mkdir dir="${hdocResultPath}"/>
<!-- Making tmp xml wikipedia file without some elements which are not useful -->
<xslt classpath="lib/saxon9he.jar" in="input/${inputFile}" out="${tmpFolderPath}/${filename}_prepared.xml" style="${xsltFolderPath}/prepare_wiki_to_hdoc.xsl">
<xslt classpath="lib/saxon9he.jar" in="${inputFile}" out="${tmpFolderPath}/${filename}_prepared.xml" style="${xsltFolderPath}/prepare_wiki_to_hdoc.xsl">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
......
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