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 ...@@ -20,6 +20,10 @@ Dependencies
--- ---
There's no particular dependencies needed to run the converter. 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 User Story
--- ---
### Running the script ### Running the script
......
...@@ -102,58 +102,235 @@ ...@@ -102,58 +102,235 @@
</sp:shortActivity> </sp:shortActivity>
</xsl:template> </xsl:template>
<!-- if Section has sub section(s), we create a real activity to print differents possible types of sub sections --> <!-- Toutes les introductions de sections sont transformés en résumé. -->
<xsl:template match="h:header/h:div[@data-hdoc-type = 'introduction']">
<sp:abstract>
<cp:txtDesc>
<sc:para xml:space="preserve">
<xsl:value-of select="./text()"/>
</sc:para>
</cp:txtDesc>
</sp:abstract>
</xsl:template>
<!-- CanoProf's Activite TetM = hdoc's body/Section/Section = Opale's Grain -->
<xsl:template match="h:body/h:section/h:section"> <xsl:template match="h:body/h:section/h:section">
<xsl:if test="./*">
<sp:textActivity> <sp:textActivity>
<cp:textActivity> <cp:textActivity>
<cp:activityM> <cp:activityM>
<sp:title> <sp:title>
<xsl:if test="not(./h:header/h:h1/text())"> Untitled </xsl:if>
<xsl:value-of select="./h:header/h:h1"/> <xsl:value-of select="./h:header/h:h1"/>
</sp:title> </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> </cp:activityM>
<xsl:if test="./h:section"> <xsl:if test="./h:div/*">
<sp:body> <sp:body>
<cp:blocks> <cp:blocks>
<xsl:apply-templates select="./*"/> <xsl:apply-templates select="./h:div"/>
</cp:blocks> </cp:blocks>
</sp:body> </sp:body>
</xsl:if> </xsl:if>
<xsl:if test="./h:section/*">
<xsl:apply-templates select="./h:section" mode="CanoprofSection"/>
</xsl:if>
</cp:textActivity> </cp:textActivity>
</sp:textActivity> </sp:textActivity>
</xsl:if>
</xsl:template> </xsl:template>
<!-- Toutes les introductions de sections sont transformés en résumé. --> <!-- CanoProf's Activite TetM (section) = hdoc's body/Section/Section/(Section...) = Opale's Grain (partie) -->
<xsl:template match="h:header/h:div[@data-hdoc-type = 'introduction']"> <!-- TODO -->
<sp:abstract> <xsl:template match="h:section" mode="CanoprofSection">
<cp:txtDesc>
<sc:para xml:space="preserve">
<xsl:value-of select="./text()"/>
</sc:para>
</cp:txtDesc>
</sp:abstract>
</xsl:template> </xsl:template>
<!-- Gestion des définitions. --> <!-- Div related templates -->
<xsl:template match="h:div[@data-hdoc-type = 'definition']|h:div[@data-hdoc-type = 'example']"> <!-- Formatting content based on @data-hdoc-type -->
<!-- <xsl:variable name="vtype" select="./@data-hdoc-type/text()"/> <xsl:template match="h:div">
<xsl:element name="{$vtype}">--> <xsl:choose>
<sp:definition> <!-- 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:block>
<cp:blockM> <cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title> <sp:title>
<xsl:value-of select="./h:h6"/> <xsl:value-of select="./h:h6"/>
</sp:title> </sp:title>
</xsl:if>
</cp:blockM> </cp:blockM>
<sp:body> <sp:body>
<cp:flow> <cp:flow>
<xsl:if test="./h:p/text()">
<xsl:apply-templates select="./*"/> <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> </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> </cp:flow>
</sp:body> </sp:body>
</cp:block> </cp:block>
</sp:definition> </sp:definition>
<!--</xsl:element>--> </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:apply-templates select="./*"/>
</cp:flow>
</sp:body>
-->
</xsl:otherwise>
</xsl:choose>
</xsl:template> </xsl:template>
<!-- Text related templates --> <!-- Text related templates -->
......
Supports Markdown
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