hdoc_to_neo4j.xsl 2.83 KB
Newer Older
Esquilax76's avatar
Esquilax76 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
    exclude-result-prefixes="xs"
    version="2.0">
    
    <xsl:output method="text" indent="no"/>
   
    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="head"/>
    
Tyrannas's avatar
Tyrannas committed
16 17
    <xsl:template match="body">
        MERGE (i:module {title:"<xsl:value-of select="concat(../head/title,' (',string-length(.), ')')"/>"});
Esquilax76's avatar
Esquilax76 committed
18
        <xsl:apply-templates select="./section"/>
Esquilax76's avatar
Esquilax76 committed
19 20 21
    </xsl:template>
    
    <xsl:template match="body/section">
Esquilax76's avatar
Esquilax76 committed
22 23
        MERGE (i:<xsl:value-of select="./@data-hdoc-type"/> {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"});
        MATCH (l1 {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"}), (l2 {title:"<xsl:value-of select="concat(ancestor::html/head/title,' (',string-length(ancestor::html/body), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
Esquilax76's avatar
Esquilax76 committed
24 25 26 27
        <xsl:apply-templates select="./section"/>
    </xsl:template>
    
    <xsl:template match="body/section/section">
Esquilax76's avatar
Esquilax76 committed
28 29
        MERGE (i:<xsl:value-of select="./@data-hdoc-type"/> {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"});
        MATCH (l1 {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"}), (l2 {title:"<xsl:value-of select="concat(parent::section/header/h1,' (',string-length(parent::section), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
Esquilax76's avatar
Esquilax76 committed
30 31 32 33
        <xsl:apply-templates select="./section"/>
    </xsl:template>
    
    <!-- Traitement spécial pour les objectifs, ils ont parfois la même longueur -->
Esquilax76's avatar
Esquilax76 committed
34
    <xsl:template match="body/section/section/section[@data-hdoc-type='aims' or @data-hdoc-type='synthesis']">
Esquilax76's avatar
Esquilax76 committed
35 36 37 38
        MERGE (i:<xsl:value-of select="./@data-hdoc-type"/> {title:"<xsl:value-of select="concat(./header/h1,' - ', parent::section/header/h1, ' (',string-length(.), ')')"/>"});
        MATCH (l1 {title:"<xsl:value-of select="concat(./header/h1,' - ', parent::section/header/h1, ' (',string-length(.), ')')"/>"}), (l2 {title:"<xsl:value-of select="concat(parent::section/header/h1,' (',string-length(parent::section), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
    </xsl:template>
    
Esquilax76's avatar
Esquilax76 committed
39
    <xsl:template match="body/section/section/section[not(@data-hdoc-type='aims' or @data-hdoc-type='synthesis')]">
Esquilax76's avatar
Esquilax76 committed
40 41
        MERGE (i:<xsl:value-of select="./@data-hdoc-type"/> {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"});
        MATCH (l1 {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"}), (l2 {title:"<xsl:value-of select="concat(parent::section/header/h1,' (',string-length(parent::section), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
Esquilax76's avatar
Esquilax76 committed
42
    </xsl:template>
Tyrannas's avatar
Tyrannas committed
43
     
Esquilax76's avatar
Esquilax76 committed
44
</xsl:stylesheet>