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
fd926056
Commit
fd926056
authored
Dec 22, 2016
by
Benoit Villain
Browse files
Passage de hdoc_to_canoprof à la V2 (vérif faites)
parent
314a360a
Changes
3
Show whitespace changes
Inline
Side-by-side
hdoc_to_canoprof/README.md
View file @
fd926056
...
...
@@ -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
...
...
hdoc_to_canoprof/samples/Sample_V2.hdoc
0 → 100644
View file @
fd926056
File added
hdoc_to_canoprof/xsl/transformation2.xsl
View file @
fd926056
...
...
@@ -102,58 +102,235 @@
</sp:shortActivity>
</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: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:
section
"
>
<xsl:if
test=
"./h:
div/*
"
>
<sp:body>
<cp:blocks>
<xsl:apply-templates
select=
"./
*
"
/>
<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>
<!-- 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>
<!-- 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>
<!-- 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>
<!-- 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:if
test=
"./h:p/text()"
>
<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: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>
<!-- Text related templates -->
...
...
Write
Preview
Supports
Markdown
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