Commit 1a3ea405 authored by Hachem Rihab's avatar Hachem Rihab
Browse files

[hdoc_to_optim] numbered sections

parent 2e02c1e8
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:sc="http://www.utc.fr/ics/scenari/v3/core"
xmlns:of="scpf.org:office"
xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive"
xmlns:h="http://www.utc.fr/ics/hdoc/xhtml">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:sc="http://www.utc.fr/ics/scenari/v3/core" xmlns:of="scpf.org:office"
xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive" xmlns:h="http://www.utc.fr/ics/hdoc/xhtml"
xmlns:java="http://www.java.com/">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="h:html">
<sc:item xmlns:sc="http://www.utc.fr/ics/scenari/v3/core">
<of:paper xmlns:of="scpf.org:office" xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive" xmlns:sc="http://www.utc.fr/ics/scenari/v3/core">
<of:paper xmlns:of="scpf.org:office"
xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive"
xmlns:sc="http://www.utc.fr/ics/scenari/v3/core">
<xsl:apply-templates/>
</of:paper>
</sc:item>
......@@ -53,7 +53,7 @@
</sp:pre>
</xsl:if>
</xsl:template>
<xsl:template match="h:meta[@name='description'] | h:meta[@name='keywords']">
<sp:info>
<of:block>
......@@ -61,7 +61,7 @@
<sp:title>
<xsl:if test="@name='description'">Description</xsl:if>
<xsl:if test="@name='keywords'">Keywords</xsl:if>
</sp:title>
</sp:title>
</of:blockM>
<sp:co>
<of:flow>
......@@ -77,70 +77,113 @@
</of:block>
</sp:info>
</xsl:template>
<xsl:template match="h:title | h:h1 | h:h6">
<sp:title><xsl:value-of select="."/></sp:title>
<sp:title>
<xsl:value-of select="."/>
</sp:title>
</xsl:template>
<xsl:template match="h:body">
<xsl:apply-templates/>
</xsl:template>
<!--hdoc sections can become chapters or sections in Optim, we must differentiate the two-->
<xsl:template match="h:body/h:section">
<xsl:variable name="chapi" select="(.//text())[1]"/>
<xsl:message><xsl:value-of select="$chapi"/></xsl:message>
<xsl:variable name="chap">
<xsl:choose>
<xsl:when test="contains($chapi,':')">
<xsl:message>Yescontiiii!</xsl:message>
<xsl:value-of select="normalize-space(replace($chapi,':','-'))"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space($chapi)"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:message><xsl:value-of select="$chap"/></xsl:message>
<xsl:message>test</xsl:message>
<sp:chap sc:refUri="chapitres/{$chap}.section">
<xsl:variable name="chapi" select="(.//text())[1]"/>
<xsl:message>
<xsl:value-of select="$chapi"/>
</xsl:message>
<xsl:variable name="chap-norm">
<xsl:choose>
<xsl:when test="contains($chapi,':')">
<xsl:message>Yescontiiii!</xsl:message>
<xsl:value-of select="normalize-space(replace($chapi,':','-'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space($chapi)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:message>
<xsl:value-of select="$chap-norm"/>
</xsl:message>
<xsl:variable name="secNum">
<xsl:number count="h:body/h:section" format="1" level="any"/>
</xsl:variable>
<xsl:variable name="chap-num">
<!--<xsl:value-of select="concat('chapitres/',$chap,'.section')"/>-->
<xsl:value-of select="concat($secNum,'-',$chap-norm)"/>
</xsl:variable>
<xsl:message>
<xsl:value-of select="$chap-num"/>
</xsl:message>
<!--<xsl:choose>-->
<!-- if section name already exists -->
<!-- <xsl:when test="fs:exists(fs:new('chapitres/{$chap}.section'))" xmlns:fs="java.io.File">-->
<!--<xsl:when test="document(string('chapitres/{$chap}.section'))">
<xsl:when test="document($path)">-->
<!--<xsl:when test="document($path)">
<xsl:message>File exists... renaming section</xsl:message>
<xsl:variable name="chap2">
<xsl:value-of select="concat('chapitres/{$chap}.section','2')"/>
</xsl:variable>
<xsl:message><xsl:value-of select="$chap2"/></xsl:message>
<sp:chap sc:refUri="chapitres/{$chap2}.section">
<xsl:call-template name="sec-body1">
<xsl:with-param name="chap" select = "$chap2" />
</xsl:call-template>
</sp:chap>
</xsl:when>-->
<!-- else use this one -->
<!--<xsl:otherwise>
<xsl:message>File does not exist... Ok !</xsl:message>-->
<sp:chap sc:refUri="chapitres/{$chap-num}.section">
<xsl:call-template name="sec-body1">
<xsl:with-param name="chap" select = "$chap" />
</xsl:call-template>
<xsl:with-param name="chap" select="$chap-num"/>
</xsl:call-template>
</sp:chap>
<!--</xsl:otherwise>-->
<!--</xsl:choose>-->
</xsl:template>
<xsl:template match="h:section">
<sp:sec>
<xsl:call-template name="sec-body"/>
</sp:sec>
</xsl:template>
<xsl:template name="sec-body1">
<xsl:param name = "chap" />
<xsl:message><xsl:value-of select="$chap"/></xsl:message>
<xsl:result-document encoding="UTF-8" href="chapitres/{$chap}.section" >
<sc:item xmlns:sc="http://www.utc.fr/ics/scenari/v3/core">
<of:section>
<xsl:if test="@data-hdoc-type='introduction'">
<xsl:comment>Introduction</xsl:comment>
</xsl:if>
<xsl:if test="@data-hdoc-type='conclusion'">
<xsl:comment>Conclusion</xsl:comment>
</xsl:if>
<xsl:apply-templates select="h:header"/>
<xsl:if test="./h:div">
<sp:content>
<of:fragment>
<xsl:apply-templates select="h:div"/>
</of:fragment>
</sp:content>
</xsl:if>
<xsl:apply-templates select="h:section"/>
</of:section>
</sc:item>
</xsl:result-document>
<xsl:template name="sec-body1">
<xsl:param name="chap"/>
<xsl:message>
<xsl:value-of select="$chap"/>
</xsl:message>
<xsl:result-document encoding="UTF-8" href="chapitres/{$chap}.section">
<sc:item xmlns:sc="http://www.utc.fr/ics/scenari/v3/core">
<of:section>
<xsl:if test="@data-hdoc-type='introduction'">
<xsl:comment>Introduction</xsl:comment>
</xsl:if>
<xsl:if test="@data-hdoc-type='conclusion'">
<xsl:comment>Conclusion</xsl:comment>
</xsl:if>
<xsl:apply-templates select="h:header"/>
<xsl:if test="./h:div">
<sp:content>
<of:fragment>
<xsl:apply-templates select="h:div"/>
</of:fragment>
</sp:content>
</xsl:if>
<xsl:apply-templates select="h:section"/>
</of:section>
</sc:item>
</xsl:result-document>
<xsl:apply-templates select="h:footer"/>
</xsl:template>
<xsl:template name="sec-body">
<of:section>
<xsl:if test="@data-hdoc-type='introduction'">
......@@ -161,17 +204,17 @@
</of:section>
<xsl:apply-templates select="h:footer"/>
</xsl:template>
<xsl:template match="h:header">
<of:sectionM>
<xsl:apply-templates/>
</of:sectionM>
</xsl:template>
<xsl:template match="h:footer">
<xsl:apply-templates/>
</xsl:template>
<!--there are no tags for metadata in Optim sections, so we add this information in the comments-->
<xsl:template match="h:div[@data-hdoc-type]">
<xsl:comment>
......@@ -182,14 +225,15 @@
<xsl:if test="@data-hdoc-type='categories'">Categories : <xsl:for-each select="h:span"><xsl:value-of select="."/>, </xsl:for-each></xsl:if>
</xsl:comment>
</xsl:template>
<xsl:template match="h:div">
<sp:info>
<xsl:call-template name="div-body"/>
</sp:info>
</xsl:template>
<xsl:template match="h:div[@data-hdoc-type='emphasis'] | h:div[@data-hdoc-type='definition'] | h:div[@data-hdoc-type='warning']">
<xsl:template
match="h:div[@data-hdoc-type='emphasis'] | h:div[@data-hdoc-type='definition'] | h:div[@data-hdoc-type='warning']">
<sp:emphasis>
<xsl:if test="@data-hdoc-type='definition'">
<xsl:comment>Definition</xsl:comment>
......@@ -201,8 +245,9 @@
<xsl:call-template name="div-body"/>
</sp:emphasis>
</xsl:template>
<xsl:template match="h:div[@data-hdoc-type='complement'] | h:div[@data-hdoc-type='example'] | h:div[@data-hdoc-type='remark'] | h:div[@data-hdoc-type='advice']">
<xsl:template
match="h:div[@data-hdoc-type='complement'] | h:div[@data-hdoc-type='example'] | h:div[@data-hdoc-type='remark'] | h:div[@data-hdoc-type='advice']">
<sp:extra>
<xsl:if test="@data-hdoc-type='example'">
<xsl:comment>Example</xsl:comment>
......@@ -216,7 +261,7 @@
<xsl:call-template name="div-body"/>
</sp:extra>
</xsl:template>
<xsl:template name="div-body">
<of:block>
<of:blockM>
......@@ -233,63 +278,63 @@
</sp:co>
</of:block>
</xsl:template>
<xsl:template match="h:span">
<xsl:apply-templates/>
</xsl:template>
<!--Text-->
<!--paragraph-->
<!--paragraph-->
<xsl:template match="h:p">
<sc:para xml:space="preserve">
<xsl:apply-templates/>
</sc:para>
</xsl:template>
<!--list-->
<xsl:template match="h:ul">
<sc:itemizedList>
<xsl:apply-templates/>
</sc:itemizedList>
</xsl:template>
<xsl:template match="h:ol">
<sc:orderedList>
<xsl:apply-templates/>
</sc:orderedList>
</xsl:template>
<xsl:template match="h:li">
<sc:listItem>
<xsl:apply-templates/>
</sc:listItem>
</xsl:template>
<!--url-->
<xsl:template match="h:a">
<sc:uLink role="url" url="{@href}">
<xsl:apply-templates/>
</sc:uLink>
</xsl:template>
<xsl:template match="h:em">
<sc:inlineStyle role="emphasis">
<xsl:apply-templates/>
</sc:inlineStyle>
</xsl:template>
<xsl:template match="h:i">
<sc:phrase role="special">
<xsl:apply-templates/>
</sc:phrase>
</xsl:template>
<xsl:template match="h:q">
<sc:phrase role="quote">
<xsl:apply-templates/>
</sc:phrase>
</xsl:template>
<!--Table-->
<xsl:template match="h:table">
<sc:table role="">
......@@ -300,47 +345,47 @@
<xsl:apply-templates select="h:tr"/>
</sc:table>
</xsl:template>
<xsl:template match="h:caption">
<sc:caption xml:space="preserve">
<xsl:value-of select="."/>
</sc:caption>
</xsl:template>
<xsl:template match="h:tr">
<sc:row>
<xsl:apply-templates/>
</sc:row>
</xsl:template>
<xsl:template match="h:td">
<sc:cell>
<xsl:apply-templates/>
</sc:cell>
</xsl:template>
<!--Object-->
<xsl:template match="h:object">
<xsl:variable name="data" select="@data"/>
<sc:extBlock role="img" sc:refUri="../{$data}"/>
</xsl:template>
<!--Image-->
<xsl:template match="h:img">
<xsl:variable name="src" select="@src"/>
<sc:extBlock role="img" sc:refUri="../{$src}"/>
</xsl:template>
<!--Audio-->
<xsl:template match="h:audio">
<xsl:variable name="src" select="@src"/>
<sc:extBlock role="anim" sc:refUri="../{$src}"/>
</xsl:template>
<!--Video-->
<!--Video-->
<xsl:template match="h:video">
<xsl:variable name="src" select="@src"/>
<sc:extBlock role="anim" sc:refUri="../{$src}"/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
</xsl:stylesheet>
......@@ -91,7 +91,7 @@
<xsl:template match="h:body/h:section">
<xsl:variable name="chapi" select="(.//text())[1]"/>
<xsl:message><xsl:value-of select="$chapi"/></xsl:message>
<xsl:variable name="chap">
<xsl:variable name="chap-norm">
<xsl:choose>
<xsl:when test="contains($chapi,':')">
<xsl:message>Yescontiiii!</xsl:message>
......@@ -100,11 +100,19 @@
<xsl:otherwise><xsl:value-of select="normalize-space($chapi)"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:message><xsl:value-of select="$chap"/></xsl:message>
<xsl:message><xsl:value-of select="$chap-norm"/></xsl:message>
<xsl:message>test</xsl:message>
<sp:slide sc:refUri="slides/{$chap}.section">
<xsl:variable name="secNum">
<xsl:number count="h:body/h:section" format="1" level="any"/>
</xsl:variable>
<xsl:variable name="chap-num">
<xsl:value-of select="concat($secNum,'-',$chap-norm)"/>
</xsl:variable>
<sp:slide sc:refUri="slides/{$chap-num}.section">
<xsl:call-template name="sec-body1">
<xsl:with-param name="chap" select = "$chap" />
<xsl:with-param name="chap" select = "$chap-num" />
</xsl:call-template>
</sp:slide>
</xsl:template>
......
......@@ -91,7 +91,7 @@
<xsl:template match="h:body/h:section">
<xsl:variable name="chapi" select="(.//text())[1]"/>
<xsl:message><xsl:value-of select="$chapi"/></xsl:message>
<xsl:variable name="chap">
<xsl:variable name="chap-norm">
<xsl:choose>
<xsl:when test="contains($chapi,':')">
<xsl:message>Yescontiiii!</xsl:message>
......@@ -100,14 +100,23 @@
<xsl:otherwise><xsl:value-of select="normalize-space($chapi)"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:message><xsl:value-of select="$chap"/></xsl:message>
<xsl:message><xsl:value-of select="$chap-norm"/></xsl:message>
<xsl:message>test</xsl:message>
<sp:page sc:refUri="pages/{$chap}.section">
<xsl:variable name="secNum">
<xsl:number count="h:body/h:section" format="1" level="any"/>
</xsl:variable>
<xsl:variable name="chap-num">
<xsl:value-of select="concat($secNum,'-',$chap-norm)"/>
</xsl:variable>
<sp:page sc:refUri="pages/{$chap-num}.section">
<of:filter/>
<xsl:call-template name="sec-body1">
<xsl:with-param name="chap" select = "$chap" />
<xsl:with-param name="chap" select = "$chap-num" />
</xsl:call-template>
</sp:page>
</xsl:template>
<xsl:template match="h:section">
......
......@@ -86,11 +86,17 @@
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="h:body/h:section[1]" priority="2">
<sp:main>
<xsl:call-template name="sec-body"/>
</sp:main>
</xsl:template>
<!--hdoc sections can become chapters or sections in Optim, we must differentiate the two-->
<xsl:template match="h:body/h:section">
<xsl:variable name="chapi" select="(.//text())[1]"/>
<xsl:message><xsl:value-of select="$chapi"/></xsl:message>
<xsl:variable name="chap">
<xsl:variable name="chap-norm">
<xsl:choose>
<xsl:when test="contains($chapi,':')">
<xsl:message>Yescontiiii!</xsl:message>
......@@ -99,21 +105,23 @@
<xsl:otherwise><xsl:value-of select="normalize-space($chapi)"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:message><xsl:value-of select="$chap"/></xsl:message>
<xsl:message><xsl:value-of select="$chap-norm"/></xsl:message>
<xsl:message>test</xsl:message>
<sp:subPage sc:refUri="pages/{$chap}.section">
<xsl:variable name="secNum">
<xsl:number count="h:body/h:section" format="1" level="any"/>
</xsl:variable>
<xsl:variable name="chap-num">
<xsl:value-of select="concat($secNum,'-',$chap-norm)"/>
</xsl:variable>
<sp:subPage sc:refUri="pages/{$chap-num}.section">
<of:filter/>
<xsl:call-template name="sec-body1">
<xsl:with-param name="chap" select = "$chap" />
<xsl:with-param name="chap" select = "$chap-num" />
</xsl:call-template>
</sp:subPage>
</xsl:template>
<xsl:template match="h:body/h:section[1]">
<sp:main>
<xsl:call-template name="sec-body"/>
</sp:main>
</xsl:template>
<xsl:template match="h:section">
<sp:sec>
......
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