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
8802ec1b
Commit
8802ec1b
authored
Dec 31, 2016
by
Kapilraj Thangeswaran
Browse files
Ajout attribut exercices
parent
9d970a0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
hdoc_to_mongo/xsl/main.xsl
View file @
8802ec1b
...
...
@@ -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>
...
...
hdoc_to_mongo/xsl/subroutines/exercise.xsl
0 → 100644
View file @
8802ec1b
<?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
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