Commit 0b5f35cc authored by Vincent Keller's avatar Vincent Keller

Add exercises support, fix ant issues

parent 3fa1a049
<?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">
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 omit-xml-declaration="yes"
encoding="UTF-8">
encoding="UTF-8">
<!-- Encodage UTF-8 pour caractères spéciaux (accents...) -->
</xsl:output>
<!-- On remplace les quotes dans le texte pour éviter les problèmes de JSON -->
<xsl:param name="pPattern">"</xsl:param>
<xsl:param name="pReplacement">\\"</xsl:param>
<!-- -->
<xsl:template match="/" >
{
<xsl:apply-templates select="html"/>
}
{
<xsl:apply-templates select="html"/>
}
</xsl:template>
<!-- Extraction des informations du head -->
......@@ -25,18 +26,21 @@
"title" : "<xsl:value-of select="title/text()"/>",
"keywords" : [
<xsl:for-each select="meta[@name='keywords']">
"<xsl:value-of select="@content"/>"<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
<xsl:for-each select="meta[@name='keywords']">
"<xsl:value-of select="@content"/>"<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
],
<xsl:apply-templates select="meta"/>
</xsl:template>
<!-- Extraction des informations du body -->
<xsl:template match="body" />
<xsl:template match="body">
<!-- Extraction des sections -->
<xsl:apply-templates select="*/section[@data-hdoc-type='exercise']"/>
</xsl:template>
<xsl:template match="meta[@name='author']">
"author" : "<xsl:value-of select="@content"/>"
"author" : "<xsl:value-of select="@content"/>",
</xsl:template>
<xsl:template match="meta[@name='date']">
......@@ -47,6 +51,46 @@
"rights" : "<xsl:value-of select="@content"/>",
</xsl:template>
<!-- Traitement des sections -->
<xsl:template match="section[not(@data-hdoc-type='exercise')]"/>
<xsl:template match="section[@data-hdoc-type='exercise']">
"exercice_<xsl:value-of select="generate-id()"/>" : {
"titre" : "<xsl:value-of select="normalize-space(replace(header/h1/text(),$pPattern,$pReplacement))"/>",
<xsl:apply-templates select="div[@data-hdoc-type='description']"/>
} <xsl:if test=". != (//section[@data-hdoc-type='exercise'])[last()] or div[@data-hdoc-type='question']">,</xsl:if>
<!-- On test si c'est le dernier exercice et qu'il n'a pas de question -->
<xsl:apply-templates select="div[@data-hdoc-type='question']">
<xsl:with-param name="prev_id" select="generate-id()"/>
<xsl:with-param name="is_not_last" select=". != (//section[@data-hdoc-type='exercise'])[last()]"/>
</xsl:apply-templates>
</xsl:template>
<!-- Traitement des question -->
<xsl:template match="div[@data-hdoc-type='question']">
<xsl:param name="prev_id"/>
<xsl:param name="is_not_last"/>
"question_<xsl:value-of select="generate-id()"/>" : {
"parent" : "exercice_<xsl:value-of select="$prev_id"/>",
<xsl:apply-templates select="div[@data-hdoc-type='description']"/>
<xsl:apply-templates select="div[@data-hdoc-type='solution']"/>
}<xsl:if test="((position() != last()) or $is_not_last)">,</xsl:if>
<!-- On test si c'est le dernier exercice et la dernière question -->
</xsl:template>
<!-- Traitement de l'élément description -->
<xsl:template match="div[@data-hdoc-type='description']">
"description" : "<xsl:value-of select="normalize-space(replace(./text(),$pPattern,$pReplacement))"/>"
</xsl:template>
<!-- Traitement de l'élément solution -->
<xsl:template match="div[@data-hdoc-type='solution']">
,"solution" : "<xsl:value-of select="normalize-space(replace(./text(),$pPattern,$pReplacement))"/>"
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
......@@ -25,17 +25,20 @@
</fileset>
</delete>
<!-- Copy files in opale_to_hdoc input dir -->
<mkdir dir="${inputOpaleToHdoc}" />
<copy todir="${inputOpaleToHdoc}">
<fileset dir="${inputPath}"/>
</copy>
<!-- Use ant transo opale_to_hdoc -->
<ant antfile="../opale_to_hdoc/opale_to_hdoc.ant" inheritAll="false"/>
<!-- Copy files in hdoc_to_elasticSearch input dir -->
<mkdir dir="${inputHdocToElasticSearch}" />
<copy todir="${inputHdocToElasticSearch}">
<fileset dir="${outputOpaleToHdoc}"/>
</copy>
<!-- Use ant transo opale_to_hdoc -->
<ant antfile="../hdoc_to_elasticSearch/hdoc_to_elasticsearch.ant" inheritAll="false"/>
<mkdir dir="${outputPath}" />
<copy todir="${outputPath}" >
<fileset dir="${outputHdocToElasticSearch}"/>
</copy>
......
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