Commit fd926056 authored by Benoit Villain's avatar Benoit Villain
Browse files

Passage de hdoc_to_canoprof à la V2 (vérif faites)

parent 314a360a
......@@ -20,6 +20,10 @@ Dependencies
---
There's no particular dependencies needed to run the converter.
Conditions particulières
---
Pour le moment, il ne faut pas utilisé les "sous-Division" de Opale. Les divisions à la racine sont autorisées.
User Story
---
### Running the script
......
......@@ -102,26 +102,6 @@
</sp:shortActivity>
</xsl:template>
<!-- if Section has sub section(s), we create a real activity to print differents possible types of sub sections -->
<xsl:template match="h:body/h:section/h:section">
<sp:textActivity>
<cp:textActivity>
<cp:activityM>
<sp:title>
<xsl:value-of select="./h:header/h:h1"/>
</sp:title>
</cp:activityM>
<xsl:if test="./h:section">
<sp:body>
<cp:blocks>
<xsl:apply-templates select="./*"/>
</cp:blocks>
</sp:body>
</xsl:if>
</cp:textActivity>
</sp:textActivity>
</xsl:template>
<!-- Toutes les introductions de sections sont transformés en résumé. -->
<xsl:template match="h:header/h:div[@data-hdoc-type = 'introduction']">
<sp:abstract>
......@@ -133,27 +113,224 @@
</sp:abstract>
</xsl:template>
<!-- Gestion des définitions. -->
<xsl:template match="h:div[@data-hdoc-type = 'definition']|h:div[@data-hdoc-type = 'example']">
<!-- <xsl:variable name="vtype" select="./@data-hdoc-type/text()"/>
<xsl:element name="{$vtype}">-->
<sp:definition>
<cp:block>
<cp:blockM>
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</cp:blockM>
<!-- CanoProf's Activite TetM = hdoc's body/Section/Section = Opale's Grain -->
<xsl:template match="h:body/h:section/h:section">
<xsl:if test="./*">
<sp:textActivity>
<cp:textActivity>
<cp:activityM>
<sp:title>
<xsl:if test="not(./h:header/h:h1/text())"> Untitled </xsl:if>
<xsl:value-of select="./h:header/h:h1"/>
</sp:title>
<xsl:if test="(./h:header/h:div[@data-hdoc-type = 'introduction']/text())">
<xsl:apply-templates
select="./h:header/h:div[@data-hdoc-type = 'introduction']"/>
</xsl:if>
</cp:activityM>
<xsl:if test="./h:div/*">
<sp:body>
<cp:blocks>
<xsl:apply-templates select="./h:div"/>
</cp:blocks>
</sp:body>
</xsl:if>
<xsl:if test="./h:section/*">
<xsl:apply-templates select="./h:section" mode="CanoprofSection"/>
</xsl:if>
</cp:textActivity>
</sp:textActivity>
</xsl:if>
</xsl:template>
<!-- CanoProf's Activite TetM (section) = hdoc's body/Section/Section/(Section...) = Opale's Grain (partie) -->
<!-- TODO -->
<xsl:template match="h:section" mode="CanoprofSection">
</xsl:template>
<!-- Div related templates -->
<!-- Formatting content based on @data-hdoc-type -->
<xsl:template match="h:div">
<xsl:choose>
<!-- hdoc's explanation = canoprof's information (NOT EXPLICIT...) -->
<xsl:when test="./@data-hdoc-type = 'explanation'">
<sp:info>
<cp:block>
<xsl:if test="string-length(./h:h6/text()) > 0">
<cp:blockM>
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</cp:blockM>
</xsl:if>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:info>
</xsl:when>
<!-- hdoc's warning = canoprof's warning -->
<xsl:when test="./@data-hdoc-type = 'warning'">
<sp:warning>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:warning>
</xsl:when>
<!-- hdoc's complement = canoprof's complement (extra) -->
<xsl:when test="./@data-hdoc-type = 'complement'">
<sp:extra>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:extra>
</xsl:when>
<!-- hdoc's advice = canoprof's advice -->
<xsl:when test="./@data-hdoc-type = 'advice'">
<sp:advice>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:advice>
</xsl:when>
<!-- hdoc's definition = canoprof's definition -->
<xsl:when test="./@data-hdoc-type = 'definition'">
<sp:definition>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:definition>
</xsl:when>
<!-- hdoc's example = canoprof's example -->
<xsl:when test="./@data-hdoc-type = 'example'">
<sp:example>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:example>
</xsl:when>
<!-- hdoc's remark = canoprof's hypothesis (NOT EXPLICIT...) -->
<xsl:when test="./@data-hdoc-type = 'remark'">
<sp:hypothesis>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:hypothesis>
</xsl:when>
<!-- hdoc's emphasis = canoprof's method (NOT EXPLICIT...) -->
<xsl:when test="./@data-hdoc-type = 'emphasis'">
<sp:method>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:method>
</xsl:when>
<!-- hdoc's autres or no attribute = canoprof's information-->
<xsl:otherwise>
<sp:info>
<cp:block>
<xsl:if test="string-length(./h:h6/text()) > 0">
<cp:blockM>
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</cp:blockM>
</xsl:if>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:info>
<!--
<sp:body>
<cp:flow>
<xsl:if test="./h:p/text()">
<xsl:apply-templates select="./*"/>
</xsl:if>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:definition>
<!--</xsl:element>-->
-->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Text related templates -->
......
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