Commit caa2e203 authored by Gregory's avatar Gregory
Browse files

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

parents f194c1a3 349c6133
<?xml version="1.0" encoding="UTF-8"?>
<?target hdoc/content.xml ?>
<xsl:stylesheet version="2.0" xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h2m="http://www.utc.fr/hdoc/hdoc_to_mongo">
<xsl:import href="../xsl-import/string.xsl"/>
<xsl:template name="introduction-main">
<xsl:value-of select="h2m:escape-string(string-join(/html/body/section[@data-hdoc-type='introduction']/div/descendant::*/text(), ' '))"/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?target hdoc/content.xml ?>
<xsl:stylesheet version="2.0" xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h2m="http://www.utc.fr/hdoc/hdoc_to_mongo">
<xsl:import href="../xsl-import/array.xsl"/>
<xsl:template name="keyword-main">
<xsl:value-of select="h2m:array(/html/head/meta[@name='keywords']/@content)"/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?target hdoc/content.xml ?>
<xsl:stylesheet version="2.0" xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h2m="http://www.utc.fr/hdoc/hdoc_to_mongo">
<xsl:import href="../xsl-import/string.xsl"/>
<xsl:template name="right-main">
<xsl:value-of select="h2m:escape-string(/html/head/meta[@name='rights']/@content)"/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?target hdoc/content.xml ?>
<xsl:stylesheet version="2.0" xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h2m="http://www.utc.fr/hdoc/hdoc_to_mongo">
<xsl:import href="../xsl-import/string.xsl"/>
<xsl:template name="title-main">
<xsl:choose>
<xsl:when test="../section">
<xsl:call-template name="title-section"></xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="title-rootDocument"></xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="title-section">
<xsl:value-of select="h2m:escape-string(header/h1/text())"/>
</xsl:template>
<xsl:template name="title-rootDocument">
<xsl:value-of select="h2m:escape-string(/html/head/title/text())"/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h2m="http://www.utc.fr/hdoc/hdoc_to_mongo">
<xsl:import href="../xsl-import/string.xsl"/>
<xsl:function name="h2m:array">
<xsl:param name="nodeset"/>
[
<xsl:for-each select="$nodeset[not(position() = last())]">
<xsl:value-of select="h2m:escape-string(.)"/>,
</xsl:for-each>
<xsl:value-of select="h2m:escape-string($nodeset[last()])"/>
]
</xsl:function>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h2m="http://www.utc.fr/hdoc/hdoc_to_mongo">
<xsl:function name="h2m:escape-string">
<xsl:param name="value"/>
"<xsl:value-of select="replace($value, '&quot;', '\\&quot;')"/>"
</xsl:function>
</xsl:stylesheet>
\ No newline at end of file
<?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="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>
<antcall target="transformation">
<param name="file" value="${newFileName}"/>
</antcall>
<echo>${newFileName}</echo>
</sequential>
</for>
<antcall target="insertion"/>
</target>
<target name="preparation">
<echo>On initialise le dossier!</echo>
<delete dir="./output"></delete>
<mkdir dir="./output"></mkdir>
<delete dir="./input/unziped"></delete>
<mkdir dir='./input/unziped'></mkdir>
</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"/>
</exec>
</target>
<target name="testNode">
<condition property="wantToInsert">
<matches pattern="true" string="${node}"/>
</condition>
</target>
</project>
\ No newline at end of file
{
"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);
function insert(queries){
for(let i = 0; i < queries.length; ++i){
let q = queries[i];
console.log(q + ";");
if(q.indexOf('MATCH') !== -1){
setTimeout(function(){
maki.query.single(q + ';', function(status, response){
console.log("on insere un lien " + response);
});
}, 2000);
}
else{
maki.query.single(q, function(status, response){
console.log("on insere un noeud " + response);
});
}
}
}
{
"name": "hdoc_to_neo4j",
"version": "1.0.0",
"main": "insert.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Félix Alié",
"license": "ISC",
"dependencies": {
"fs": "^0.0.1-security",
"maki-sushi": "^1.0.5"
},
"devDependencies": {},
"description": ""
}
@echo off
set ant=hdoc_to_neo4j.ant
set antparam=-Dnode false;
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 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
......@@ -13,18 +13,33 @@
<xsl:template match="head"/>
<xsl:template match="body">
<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
......@@ -195,6 +195,11 @@
<text/>
</element>
</optional>
<optional>
<element name="div">
<ref name="DivType"/>
</element>
</optional>
<ref name="Flow"/>
</element>
</oneOrMore>
......
......@@ -45,6 +45,8 @@
<value>choice-correct</value>
<value>choice-incorrect</value>
<value>explanation</value>
<value>explanation-choice-correct</value>
<value>explanation-choice-incorrect</value>
</choice>
</attribute>
</optional>
......
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