Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephane Crozat
hdoc
Commits
76eaf994
Commit
76eaf994
authored
Dec 17, 2016
by
Raphaël
Browse files
Merge branch 'master' of
https://gitlab.utc.fr/crozatst/hdoc
parents
d6c25c14
c91f2ddf
Changes
13
Hide whitespace changes
Inline
Side-by-side
hdoc_to_neo4j/ant/build.xml
deleted
100644 → 0
View file @
d6c25c14
<?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
hdoc_to_neo4j/hdoc_to_neo4j.ant
View file @
76eaf994
<?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
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=
"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>
</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>
<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"
>
...
...
hdoc_to_neo4j/lib/ant-contrib.jar
0 → 100644
View file @
76eaf994
File added
hdoc_to_neo4j/node/config.json
0 → 100644
View file @
76eaf994
{
"db"
:
"neo4j"
,
"pwd"
:
"edwin007"
,
"host"
:
"localhost"
,
"path"
:
"/db/data"
,
"port"
:
"7474"
}
\ No newline at end of file
hdoc_to_neo4j/node/insert.js
View file @
76eaf994
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();
});
}
}
}
)();
}
hdoc_to_neo4j/run.bat
View file @
76eaf994
@echo
off
set
ant
=
hdoc_to_neo4j
.ant
set
antparam
=
-D
program
.param
=
%
1
set
antparam
=
-D
node
false
;
ant
-buildfile
%ant%
%antparam%
...
...
hdoc_to_neo4j/run.sh
0 → 100644
View file @
76eaf994
#!/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
hdoc_to_neo4j/runWithNode.bat
0 → 100644
View file @
76eaf994
@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%
hdoc_to_neo4j/runWithNode.sh
0 → 100644
View file @
76eaf994
#!/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
hdoc_to_neo4j/xsl/hdoc_to_neo4j.xsl
View file @
76eaf994
...
...
@@ -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:
I
tem {title:"
<xsl:value-of
select=
"./header/h1"
/>
"});
MATCH (l1:
I
tem {title:"
<xsl:value-of
select=
"./header/h1"
/>
"}), (l2:
I
tem {title:"
<xsl:value-of
select=
"parent::section/header/h1
"
/>
"})
CREATE (l1)-[:LIEN]->(l2);
MERGE (i:
i
tem {title:"
<xsl:value-of
select=
"
concat(
./header/h1
,' (',string-length(.), ')')
"
/>
"});
MATCH (l1:
i
tem {title:"
<xsl:value-of
select=
"
concat(
./header/h1
,' (',string-length(.), ')')
"
/>
"}), (l2:
i
tem {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
hdoc_to_pdf/.Rhistory
deleted
100644 → 0
View file @
d6c25c14
hdoc_to_pdf/hdoc_to_pdf.ant
View file @
76eaf994
...
...
@@ -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"
/>
...
...
hdoc_to_pdf/xsl/find_content.xsl
View file @
76eaf994
<?xml version="1.0" encoding="UTF-8"?>
<!--find_content.xsl creates a ANT file prepare_hdoc.ant-->
<xsl:stylesheet
<xsl:stylesheet
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>
</project>
</xsl:template>
<xsl:template
match=
"h:rootfiles"
>
<xsl:apply-templates/>
</xsl:template>
<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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment