Commit 76eaf994 authored by Raphaël's avatar Raphaël

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

parents d6c25c14 c91f2ddf
<?xml version="1.0" encoding="UTF-8"?>
<project name="antModule" default="main" basedir="../">
<property name="m" value="default" ></property>
<target name="main" depends="preparation">
<echo>On transforme le fichier!!</echo>
<xslt basedir="./input" destdir="./output" extension=".cql" style="./xsl/hdoc_to_neo4j.xslt"></xslt>
</target>
<target name="preparation">
<echo>On initialise le dossier!</echo>
<delete dir="./output"></delete>
<mkdir dir="./output"></mkdir>
</target>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project name="antModule" default="main" basedir="./">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="lib/ant-contrib.jar"/>
</classpath>
</taskdef>
<property name="node" value="false" ></property>
<target name="main" depends="transformation, testNode, insertion">
<echo>On a fini!!</echo>
</target>
<target name="main" depends="preparation, testNode">
<for param="filename">
<path>
<fileset dir="./input" includes="*.hdoc"/>
</path>
<sequential>
<var name="newFileName" unset="true"/>
<basename property="newFileName" file="@{filename}"/>
<antcall target="unZip">
<param name="file" value="${newFileName}"/>
</antcall>
<target name="transformation" depends="preparation">
<echo>On transforme le fichier!!</echo>
<xslt in="./input/unziped/content.xml" out="./output/result.cql" style="./xsl/hdoc_to_neo4j.xsl" classpath="./lib/saxon9he.jar">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
<antcall target="transformation">
<param name="file" value="${newFileName}"/>
</antcall>
<echo>${newFileName}</echo>
</sequential>
</for>
<antcall target="insertion"/>
</target>
<target name="preparation">
......@@ -20,9 +35,23 @@
<mkdir dir="./output"></mkdir>
<delete dir="./input/unziped"></delete>
<mkdir dir='./input/unziped'></mkdir>
<unzip src="./input/result.hdoc" dest="./input/unziped/"/>
</target>
<target name="unZip">
<unzip src="./input/${file}" dest="./input/unziped/" overwrite="false"/>
</target>
<target name="transformation">
<sequential>
<xslt in="./input/unziped/content.xml" out="./output/${file}.cql" style="./xsl/hdoc_to_neo4j.xsl" classpath="./lib/saxon9he.jar">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
<delete dir="./input/unziped"/>
<mkdir dir="./input/unziped"/>
</sequential>
</target>
<target name="insertion" if="wantToInsert">
<exec executable="node" dir="./node">
<arg line="insert.js"/>
......
{
"db":"neo4j",
"pwd":"edwin007",
"host":"localhost",
"path":"/db/data",
"port":"7474"
}
\ No newline at end of file
const fs = require('fs');
var maki = require('maki-sushi');
const config = JSON.parse(fs.readFileSync('config.json'));
const testFolder = '../output/';
fs.readdir(testFolder, (err, files) => {
files.forEach(file => {
let q = fs.readFileSync("../output/" + file).toString().replace(/[\n\t\r]/g,'').replace(/\s{4,}/g,'').split(';');
q.pop();
insert(q);
});
})
maki.config.setId(config.db,config.pwd);
maki.config.setEndpoint(config.host, config.path);
maki.config.setPort(config.port);
var queries = fs.readFileSync('../output/result.cql').toString().replace(/[\n\t\r]/g,'').replace(/\s{4,}/g,'').split(';');
queries.pop();
(function main(){
function insert(queries){
for(let i = 0; i < queries.length; ++i){
let q = queries[i];
console.log(q + ";");
......@@ -26,5 +35,5 @@ queries.pop();
});
}
}
})();
}
@echo off
set ant=hdoc_to_neo4j.ant
set antparam=-Dprogram.param=%1
set antparam=-Dnode false;
ant -buildfile %ant% %antparam%
......
#!/bin/sh
lib="lib"
ant="hdoc_to_mongo.ant"
antparam="-Dnode false"
#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
@echo off
set ant=hdoc_to_neo4j.ant
set antparam=-Dnode true;
ant -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="hdoc_to_mongo.ant"
antparam="-Dnode true"
#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
......@@ -14,17 +14,32 @@
<xsl:template match="head"/>
<xsl:template match="body">
MERGE (i:module {title:"<xsl:value-of select="concat(../head/title,' (',string-length(.), ')')"/>"});
<xsl:apply-templates select="./section"/>
</xsl:template>
<xsl:template match="body/section">
MERGE (i:Item {title:"<xsl:value-of select="./header/h1"/>"});
MERGE (i:item {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"});
MATCH (l1:item {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"}), (l2:module {title:"<xsl:value-of select="concat(ancestor::html/head/title,' (',string-length(ancestor::html/body), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
<xsl:apply-templates select="./section"/>
</xsl:template>
<xsl:template match="body/section/section">
MERGE (i:Item {title:"<xsl:value-of select="./header/h1"/>"});
MATCH (l1:Item {title:"<xsl:value-of select="./header/h1"/>"}), (l2:Item {title:"<xsl:value-of select="parent::section/header/h1"/>"})
CREATE (l1)-[:LIEN]->(l2);
MERGE (i:item {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"});
MATCH (l1:item {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"}), (l2:item {title:"<xsl:value-of select="concat(parent::section/header/h1,' (',string-length(parent::section), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
<!--<xsl:apply-templates select="./div"/>-->
</xsl:template>
<!--
<xsl:template match="body/section[@data-hdoc-type]">
MERGE (i:<xsl:value-of select="./@data-hdoc-type"/> {title:"<xsl:value-of select="./header/h1"/>"});
<xsl:apply-templates select="./section"/>
</xsl:template>
<xsl:template match="body/section[not(@data-hdoc-type)]">
MERGE (i:item {title:"<xsl:value-of select="./header/h1"/>"});
<xsl:apply-templates select="./section"/>
</xsl:template>
-->
</xsl:stylesheet>
\ No newline at end of file
......@@ -20,8 +20,8 @@
<target name="main" depends="convertMac, convertWindows, convertUnix">
<!--temporary files and folders are deleted-->
<delete dir="${tmp}"/>
<delete file="prepare_hdoc.ant"/>
<!--<delete dir="${tmp}"/>
<delete file="prepare_hdoc.ant"/>-->
</target>
<!-- Mac target -->
......@@ -88,8 +88,9 @@
<chmod dir="${tmp}" perm="777"/>
<!--launches the XSLT find_content to retrieve the content path-->
<xslt in="${tmp}/META-INF/container.xml" out="prepare_hdoc.ant" style="xsl/find_content.xsl">
<param name="TempRepository" expression="${tmp}"/>
<xslt in="${tmp}/META-INF/container.xml" out="prepare_hdoc.ant" classpath="./lib/saxon9he.jar" style="xsl/find_content.xsl">
<param name="BaseDirectory" expression="${basedir}"/>
<param name="TempDirectory" expression="${tmp}"/>
</xslt>
<chmod file="prepare_hdoc.ant" perm="777"/>
......
......@@ -4,10 +4,14 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:h="urn:utc.fr:ics:hdoc:container"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:param name="TempRepository" required="yes" as="xs:string"/>
<xsl:param name="BaseDirectory" required="yes" as="xs:string"/>
<xsl:param name="TempDirectory" required="yes" as="xs:string"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="h:container">
<project name="hdoc_to_pdf" default="main">
<project name="hdoc_to_pdf" basedir=".." default="main">
<target name="main">
<xsl:apply-templates/>
</target>
......@@ -21,8 +25,30 @@
<xsl:template match="h:rootfile">
<xsl:variable name="path" select="@full-path"/>
<xslt in="{$TempRepository}/{$path}" out="{$TempRepository}/hdoc_nsless.xhtml" style="xsl/ns_remover.xsl"/>
<xslt in="{$TempRepository}/hdoc_nsless.xhtml" out="{$TempRepository}/flat_hdoc.xhtml" style="xsl/hdoc_flattenizer.xsl"/>
<xslt in="{$TempRepository}/flat_hdoc.xhtml" out="{$TempRepository}/final.xhtml" style="xsl/last_transformer.xsl"/>
<xsl:analyze-string select="$path" regex="\.?[-_0-9a-zA-Z]+(\.[-_0-9a-zA-Z]+)?$">
<xsl:matching-substring>
<echo message="MATCHING TEST :"/>
<echo>
<xsl:attribute name="message"><xsl:value-of select="."/></xsl:attribute>
</echo>
<xsl:variable name="filename">
<xsl:value-of select="."/>
</xsl:variable>
<xsl:variable name="dirpath" select="concat($TempDirectory, '/', substring($path, 1, string-length($path) - string-length($filename) - 1))"/>
<echo message="Path : {$path}"/>
<echo message="Filename : {$filename}"/>
<echo message="Dirpath : {$dirpath}"/>
<copy file="{$BaseDirectory}/css/main.css" tofile="{$dirpath}/main.css"/>
<xslt in="{$TempDirectory}/{$path}" out="{$TempDirectory}/hdoc_nsless.xhtml" style="xsl/ns_remover.xsl" classpath="./lib/saxon9he.jar"/>
<xslt in="{$TempDirectory}/hdoc_nsless.xhtml" out="{$TempDirectory}/flat_hdoc.xhtml" style="xsl/hdoc_flattenizer.xsl" classpath="./lib/saxon9he.jar"/>
<xslt in="{$TempDirectory}/flat_hdoc.xhtml" out="{$TempDirectory}/final.xhtml" style="xsl/last_transformer.xsl" classpath="./lib/saxon9he.jar"/>
</xsl:matching-substring>
</xsl:analyze-string>
</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