Commit c3b29c6b authored by Benoit Villain's avatar Benoit Villain

Version 1 fonctionnelle

parent 52da0ebf
......@@ -54,6 +54,7 @@
</sp:abstract>
</xsl:template>
<!-- Body related templates. -->
<xsl:template match="h:body">
<xsl:if test="./*">
......@@ -66,19 +67,216 @@
<!-- CanoProf's Activite TetM = hdoc's body/Section/Section = Opale's Grain -->
<!-- CanoProf's Activite TetM (section) = hdoc's body/Section/Section/(Section...) = Opale's Grain (partie) -->
<!-- TODO :CanoProf's Seance = hdoc's body/Section = Opale's Division -->
<!-- CanoProf's Seance = hdoc's body/Section = Opale's Division or Activite-->
<xsl:template match="h:body/h:section">
<xsl:if test="./*">
<sp:session>
<cp:session>
<cp:sessionM>
<sp:title>
<xsl:if test="not(./h:header/h:h1/text())"> Untitled </xsl:if>
<xsl:value-of select="./h:header/h:h1"/>
</sp:title>
</cp:sessionM>
<xsl:apply-templates select="./*"/>
</cp:session>
</sp:session>
</xsl:if>
</xsl:template>
<!-- TODO : if Section have only a dev (no sub section), we create a short activty to print text into a seance -->
<!-- if Section have only a dev (no sub section), we create a short activty to print text into a seance -->
<xsl:template match="h:body/h:section/h:div">
<sp:shortActivity>
<cp:shortActivity>
<cp:activityM>
<sp:title>
<xsl:value-of select="../h:header/h:h1"/>
</sp:title>
</cp:activityM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:shortActivity>
</sp:shortActivity>
</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>
</xsl:template>
<!-- Text related templates -->
<xsl:template match="h:p | h:ul | h:ol">
<xsl:if test="not(preceding-sibling::h:p)">
<xsl:if test="not(preceding-sibling::h:ul)">
<xsl:if test="not(preceding-sibling::h:ol)">
<xsl:choose>
<!-- If it is directly included in a div, we have to add Canoprof's text markups -->
<xsl:when test="parent::*[name() = 'div']">
<sp:txt>
<cp:txt>
<xsl:call-template name="blockloop"/>
</cp:txt>
</sp:txt>
</xsl:when>
<!-- Otherwise, we can directly display it (this can happen when it is included within a list or a table) -->
<xsl:otherwise>
<xsl:call-template name="blockloop"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template name="blockloop">
<xsl:for-each select=". | ./following-sibling::*">
<xsl:choose>
<!-- Paragraph -->
<xsl:when test="name() = 'p' and (./* | ./text())">
<sc:para xml:space="preserve">
<xsl:apply-templates select="./* | ./text()"/>
</sc:para>
</xsl:when>
<!-- Unordered list -->
<xsl:when test="name() = 'ul' and (./h:li/h:p/text())">
<sc:itemizedList>
<xsl:apply-templates select="./* | ./text()"/>
</sc:itemizedList>
</xsl:when>
<!-- Ordered list -->
<xsl:when test="name() = 'ol' and (./h:li/h:p/text())">
<sc:orderedList>
<xsl:apply-templates select="./* | ./text()"/>
</sc:orderedList>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<!-- TODO : 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:li">
<sc:listItem>
<xsl:apply-templates select="./* | ./text()"/>
</sc:listItem>
</xsl:template>
<xsl:template match="h:i">
<xsl:if test="./* | ./text()">
<sc:inlineStyle role="specific">
<xsl:apply-templates select="./* | ./text()"/>
</sc:inlineStyle>
</xsl:if>
</xsl:template>
<xsl:template match="h:em">
<xsl:if test="./* | ./text()">
<sc:inlineStyle role="emphasis">
<xsl:apply-templates select="./* | ./text()"/>
</sc:inlineStyle>
</xsl:if>
</xsl:template>
<xsl:template match="h:q">
<xsl:if test="./* | ./text()">
<sc:phrase role="quote">
<xsl:apply-templates select="./* | ./text()"/>
</sc:phrase>
</xsl:if>
</xsl:template>
<xsl:template match="h:sub">
<xsl:if test="./* | ./text()">
<sc:textLeaf role="ind">
<xsl:apply-templates select="./* | ./text()"/>
</sc:textLeaf>
</xsl:if>
</xsl:template>
<xsl:template match="h:sup">
<xsl:if test="./* | ./text()">
<sc:textLeaf role="exp">
<xsl:apply-templates select="./* | ./text()"/>
</sc:textLeaf>
</xsl:if>
</xsl:template>
<xsl:template match="h:a">
<xsl:if test="./* | ./text()">
<sc:phrase role="url">
<cp:link xmlns:sc="http://www.utc.fr/ics/scenari/v3/core"
xmlns:cp="canope.fr:canoprof"
xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive">
<sp:url>
<xsl:value-of select="./@href"/>
</sp:url>
</cp:link>
<xsl:if test="./@title">
<sp:title>
<xsl:value-of select="./@title"/>
</sp:title>
</xsl:if>
<xsl:value-of select="."/>
</sc:phrase>
</xsl:if>
</xsl:template>
<!-- Table related templates -->
<xsl:template match="h:table">
<xsl:choose>
<xsl:when test="parent::*[name() = 'div']">
<!-- If this <table> is a direct child of a <div> then it must be surrounded by Opale's text markups. -->
<sp:txt>
<cp:txt>
<sc:table>
<xsl:if test="./h:caption">
<sc:caption>
<xsl:value-of select="./h:caption"/>
</sc:caption>
</xsl:if>
<xsl:apply-templates select="./h:tr"/>
</sc:table>
</cp:txt>
</sp:txt>
</xsl:when>
<xsl:otherwise>
<sc:table>
<xsl:if test="./h:caption">
<sc:caption>
<xsl:value-of select="./h:caption"/>
</sc:caption>
</xsl:if>
<xsl:apply-templates select="./h:tr"/>
</sc:table>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="h:tr">
<sc:row>
<xsl:apply-templates select="./h:td"/>
</sc:row>
</xsl:template>
<xsl:template match="h:td">
<sc:cell>
<xsl:apply-templates select="./*"/>
</sc:cell>
</xsl:template>
<xsl:template match="h:header"/>
<!-- Its content is already used in <xsl:template match="h:section"> -->
<xsl:template match="h:h6"/>
<!-- Its content is already used in <xsl:template match="h:div"> -->
<xsl:template match="h:h1"/>
<!-- Its content is already used in <xsl:template match="h:section"> -->
</xsl:stylesheet>
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