Commit 8802ec1b authored by Kapilraj Thangeswaran's avatar Kapilraj Thangeswaran

Ajout attribut exercices

parent 9d970a0c
......@@ -9,6 +9,7 @@
<xsl:import href="subroutines/keyword.xsl"/>
<xsl:import href="subroutines/right.xsl"/>
<xsl:import href="subroutines/introduction.xsl"/>
<xsl:import href="subroutines/exercise.xsl"/>
<xsl:output method="text" encoding="UTF-8" omit-xml-declaration="yes"/>
......@@ -18,7 +19,8 @@
"authors" : <xsl:call-template name="author-main"/>,
"keywords" : <xsl:call-template name="keyword-main"/>,
"rights" : <xsl:call-template name="right-main"/>,
"introduction" : <xsl:call-template name="introduction-main"/>
"introduction" : <xsl:call-template name="introduction-main"/>,
"exercises" : <xsl:call-template name="exercise-main"/>
}
</xsl:template>
......
<?xml version="1.0" encoding="UTF-8"?>
<?target hdoc/content.xml ?>
<xsl:stylesheet version="2.0" xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h2m="http://www.utc.fr/hdoc/hdoc_to_mongo">
<xsl:import href="../xsl-import/string.xsl"/>
<xsl:template name="exercise-main">
[
<xsl:apply-templates select="(//section[@data-hdoc-type='exercise'])[position() != last()]" mode="default"/>
<xsl:apply-templates select="(//section[@data-hdoc-type='exercise'])[last()]" mode="last"/>
]
</xsl:template>
<xsl:template match="//section[@data-hdoc-type='exercise']" mode="default">
<xsl:call-template name="exercise-object"/>,
</xsl:template>
<xsl:template match="//section[@data-hdoc-type='exercise']" mode="last">
<xsl:call-template name="exercise-object"/>
</xsl:template>
<xsl:template name="exercise-object">
{
"title" : <xsl:value-of select="h2m:escape-string(header/h1)"/>,
"description" : <xsl:value-of select="h2m:escape-string(normalize-space(string-join(div[@data-hdoc-type='description']/text(), ' ')))"/>,
"questions" : [
<xsl:apply-templates select="div[@data-hdoc-type='question']"/>
]
}
</xsl:template>
<xsl:template match="div[@data-hdoc-type='question']" >
{
<xsl:apply-templates select="div[@data-hdoc-type='description']"/>
<xsl:apply-templates select="div[@data-hdoc-type='solution']"/>
},
</xsl:template>
<xsl:template match="div[@data-hdoc-type='question'][last()]" >
{
<xsl:apply-templates select="div[@data-hdoc-type='description']"/>
<xsl:apply-templates select="div[@data-hdoc-type='solution']"/>
}
</xsl:template>
<xsl:template match="div[@data-hdoc-type='description']" >
"description" : <xsl:value-of select="h2m:escape-string(normalize-space(.))"/>
</xsl:template>
<xsl:template match="div[@data-hdoc-type='solution']" >
,"solution" : <xsl:value-of select="h2m:escape-string(normalize-space(.))"/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
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