Commit e56195eb authored by Aghiles's avatar Aghiles

fix conflict

parents c7d43a1d 9e71c987
......@@ -7,6 +7,7 @@
<target name="convert">
<antcall target="init" />
<antcall target="unzip_scar" />
<antcall target="hdoc_structure"/>
<antcall target="process_canoscar"/>
<antcall target="not_canoscar"/>
<echo message="OK" file="${out}/testfile"/>
......@@ -15,6 +16,21 @@
</target>
<!-- Create the hdoc structure -->
<target name="hdoc_structure">
<mkdir dir="${hdoc}"/>
<mkdir dir="${hdoc}/META-INF" />
<touch file="${hdoc}/META-INF/container.xml" />
<touch file="${hdoc}/mimetype" />
<echo message="application/x-hdoc+zip" file="${hdoc}/mimetype" />
<echoxml file="${hdoc}/META-INF/container.xml" namespacePolicy="elementsOnly">
<container xmlns="urn:utc.fr:ics:hdoc:container" version="1.0">
<rootfiles>
<rootfile full-path="${rootfilename}" media-type="text/xml" />
</rootfiles>
</container>
</echoxml>
</target>
<!-- Initialize folders -->
<target name="init">
......@@ -43,8 +59,10 @@
<target name="process_canoscar" depends="check_scar" if="${canoprof.is_canoprof_scar}">
<!-- TODO traitement du fichier -->
<echo file="${out}/scar_cano_or_not_scar_cano.txt" message="C'est un scar canoprof"/>
<!-- TODO change test.xml to the temporary file created while fusioning all the xml files -->
<xslt style="xsl/programmation.xsl" in="${unzipfolder}/Test/Test.programme" out="${hdoc}/content.xml" classpath="./lib/saxon9he.jar">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
</target>
<target name="not_canoscar" depends="check_scar" unless="${canoprof.is_canoprof_scar}">
......@@ -63,6 +81,11 @@
<!-- Zip the final content into a scar file -->
<target name="zip">
<!-- TODO zip the output files -->
<fileset id="fileset_scar" dir="input" casesensitive="yes">
<include name="*.scar"/>
</fileset>
<pathconvert property="scar.path" pathsep="" refid="fileset_scar" />
<basename property="filename" file="${scar.path}" suffix=".scar"/>
<zip destfile="${out}/${filename}.hdoc" basedir="${hdoc}"/>
</target>
</project>
\ No newline at end of file
......@@ -4,6 +4,7 @@ tmp = ${basedir}/tmp
xsl = ${basedir}/xsl
lib = ${basedir}/lib
log = ${basedir}/log
hdoc = ${out}/hdoc
unzipfolder = ${basedir}/unzip
cano_in = ../canoprof_to_hdoc/input
......
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs" version="2.0" xmlns:sc="http://www.utc.fr/ics/scenari/v3/core"
xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive" xmlns:op="utc.fr:ics/opale3" xmlns:cp="canope.fr:canoprof">
<xsl:template match="sp:textActivity">
<section>
<header>
<xsl:apply-templates select="cp:textActivity/cp:activityM/sp:title"/>
</header>
</section>
<!-- Blocs -->
<xsl:apply-templates select="./cp:textActivity/sp:body/cp:blocks/*"/>
<!-- Parts -->
<footer>
</footer>
</xsl:template>
<!-- Titles -->
<xsl:template match="cp:activityM/sp:title">
<h1>
<xsl:value-of select="."/>
</h1>
</xsl:template>
<xsl:template match="cp:block/cp:blockM/sp:title">
<h6>
<xsl:value-of select="."/>
</h6>
</xsl:template>
<!-- Content information -->
<xsl:template match="sp:body/cp:blocks/sp:info">
<div>
<xsl:apply-templates select="cp:block/cp:blockM/sp:title"/>
<xsl:apply-templates select="cp:block/sp:body/cp:flow/*"/>
</div>
</xsl:template>
<!-- Content definition -->
<xsl:template match="sp:body/cp:blocks/sp:def">
<div data-hdoc-type="definition">
<xsl:apply-templates select="cp:block/cp:blockM/sp:title"/>
<xsl:apply-templates select="cp:block/sp:body/cp:flow/*"/>
</div>
</xsl:template>
<!-- content example -->
<xsl:template match="sp:body/cp:blocks/sp:ex">
<div data-hdoc-type="example">
<xsl:apply-templates select="cp:block/cp:blockM/sp:title"/>
<xsl:apply-templates select="cp:block/sp:body/cp:flow/*"/>
</div>
</xsl:template>
<!-- content hypothesis-->
<xsl:template match="sp:body/cp:blocks/sp:hypothesis">
<div data-hdoc-type="remark">
<xsl:apply-templates select="cp:block/cp:blockM/sp:title"/>
<xsl:apply-templates select="cp:block/sp:body/cp:flow/*"/>
</div>
</xsl:template>
<!-- content advice -->
<xsl:template match="sp:body/cp:blocks/sp:advice">
<div data-hdoc-type="advice">
<xsl:apply-templates select="cp:block/cp:blockM/sp:title"/>
<xsl:apply-templates select="cp:block/sp:body/cp:flow/*"/>
</div>
</xsl:template>
<!-- content warning -->
<xsl:template match="sp:body/cp:blocks/sp:warning">
<div data-hdoc-type="warning">
<xsl:apply-templates select="cp:block/cp:blockM/sp:title"/>
<xsl:apply-templates select="cp:block/sp:body/cp:flow/*"/>
</div>
</xsl:template>
<!-- content rappel -->
<xsl:template match="sp:body/cp:blocks/sp:reminder">
<div data-hdoc-type="complement"> <!-- TODO change for reminder -->
<xsl:apply-templates select="cp:block/cp:blockM/sp:title"/>
<xsl:apply-templates select="cp:block/sp:body/cp:flow/*"/>
</div>
</xsl:template>
<!-- content complement -->
<xsl:template match="sp:body/cp:blocks/sp:extra">
<div data-hdoc-type="complement">
<xsl:apply-templates select="cp:block/cp:blockM/sp:title"/>
<xsl:apply-templates select="cp:block/sp:body/cp:flow/*"/>
</div>
</xsl:template>
<!-- content method -->
<xsl:template match="sp:body/cp:blocks/sp:method">
<div data-hdoc-type="advice"> <!-- TODO change for method -->
<xsl:apply-templates select="cp:block/cp:blockM/sp:title"/>
<xsl:apply-templates select="cp:block/sp:body/cp:flow/*"/>
</div>
</xsl:template>
<!-- Simple text -->
<xsl:template match="op:res/sp:txt">
<xsl:apply-templates select="./cp:txt/*"/>
</xsl:template>
<!-- Paragraph -->
<xsl:template match="sc:para">
<p>
test
<!-- TODO Gérer -->
</p>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns="http://www.utc.fr/ics/hdoc/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs" version="2.0" xmlns:sc="http://www.utc.fr/ics/scenari/v3/core"
xmlns:sp="http://www.utc.fr/ics/scenari/v3/primitive" xmlns:op="utc.fr:ics/opale3" xmlns:cp="canope.fr:canoprof"
>
<xsl:output indent="yes"/>
<xsl:template match="sc:item/cp:program">
<!-- RNG -->
<xsl:processing-instruction name="oxygen">
RNGSchema="http://hdoc.crzt.fr/schemas/xhtml/hdoc1-xhtml.rng" type="xml"
</xsl:processing-instruction>
<!-- HTML -->
<html xmlns="http://www.utc.fr/ics/hdoc/xhtml">
<head>
<xsl:apply-templates select="cp:programM/sp:title"/>
<meta charset="utf-8"/>
<meta content="HdocConverter/Opale3.4" name="generator"/>
</head>
<body>
<xsl:apply-templates select="sp:sequence/cp:sequence"/>
</body>
</html>
</xsl:template>
<!-- Sequence -->
<xsl:template match="sp:sequence/cp:sequence">
<section>
<header>
<xsl:apply-templates select="cp:sequenceM/sp:title"/>
</header>
<!-- check for seance -->
<xsl:apply-templates select="//sp:session"/>
</section>
</xsl:template>
<!-- Seance -->
<xsl:template match="sp:session">
</xsl:template>
<!-- Titles -->
<xsl:template match="cp:programM/sp:title">
<title><xsl:value-of select="."/></title>
</xsl:template>
<xsl:template match="cp:sequenceM/sp:title">
<h1><xsl:value-of select="."/></h1>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
......@@ -54,7 +54,14 @@ Example :
Currently available on: https://framemo.org/framapad_to_opale
See also : https://bimestriel.framapad.org/p/nf29_framapad_to_opale for the full documentation of our working process.
## TODO
- Nested Lists
- Indentation
- Titles (and therefore Structure of the doc)
- Coloured text
- Code
- Markdown
## Technical notes
......
......@@ -29,6 +29,17 @@ This project can be used alone if you want to import an HDOC file into basex.
- In a certain section, by searching a key word, user can obtain paragraphes that contain it.
- User can get definitions related to a keyword
- User can get examples whose titles contain a keyword
[Step 1]
- Unzip works, creation of a XML file with the title of the hdoc. (little problem, all of the document is in the output).
- the file created is in the tmp/{hdocfile} directory.
\ No newline at end of file
Step by step :
[Step 1 : File transformation]
- Put the files .hdoc you want to deal with in the folder [input](https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex/input)
- Run the transformation progam (Win : double click run.bat, Linux : execute run.sh)
[Step 2 : Create data base in basex]
- Download and install [BaseX](http://basex.org/products/download/all-downloads/)
- Run BasexGui
- In the Text Editor of BaseX, open the command script "createbd.bxs" in folder [/basex/command] (https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_basex/basex/command).
Follow the instructions in the script, and then execute it.
[Step 3 : Make XQuery request]
-
\ No newline at end of file
# This script allows for creation of a data base in baseX from the xml files in the folder output
# Before executing this script, please make sure that you have successfully finished the transformation in the step 1 in the "user story" of the README.md
# Syntax : CREATE DB [name] ([input])
# Example :
CREATE DB myDB D:\School\UTC\GI04\NF29\Projet\hdoc\hdoc_to_basex\output
#CREATE DB myDB [..the repertory of the projet in your local disk..]/hdoc/hdoc_to_basex/output
# P.S. If you get error message : Resource "..." not found, please confirm your file repertory is correct
\ No newline at end of file
(: This script will return documents by searching its author :)
(: We can assign a Regular Expression to the variable $author :)
(: For example, $author := '^Baptiste Montangé$', to search for an exact name:)
(: For example, $name := 'Montangé', to search for documents whose author named Coutant:)
(: Remark : Accents in the authors' names have been taken care of :)
<documents>{
let $name := 'Montangé'
let $name_noAcc := translate($name, 'áàâäéèêëíìîïóòôöúùûü','aaaaeeeeiiiioooouuuu')
for $doc in //document
return
for $author in $doc/authors/author
let $titre := $doc/titre
let $author_noAcc := translate($author, 'áàâäéèêëíìîïóòôöúùûü','aaaaeeeeiiiioooouuuu')
where matches($author_noAcc, $name_noAcc)
group by $titre (: Avoid duplications of documents by their titre:)
return $doc
}</documents>
\ No newline at end of file
(: This script will return documents by searching one keyword in their title :)
(: We can assign a Regular Expression to the variable $name :)
(: For example, $name := '^NF29_HdocEtherpad$', to search for an exact name:)
(: For example, $name := 'NF29', to search for documents whose name contains 'NF29':)
<documents>{
let $name := '^NF29_HdocEtherpad$'
for $doc in //document
where matches($doc/titre, $name, "i")
return $doc
}</documents>
\ No newline at end of file
......@@ -40,6 +40,7 @@
<delete dir="${tmp}" failonerror="false"/>
</target>
<target name="UnzipHdocFile">
<!-- Unzip the input hdoc file. Decompressed folder is named "decompressedHdoc" : this name is the only one which
refers to the hdoc file furthermore in this project. -->
......@@ -49,6 +50,7 @@
</target>
<target name="content" >
<!-- Transformation of a xml file decompressed from hdoc file to data xml file to be imported to basex.
The transformation will be done in terms of the xsl file in ${xsl}.-->
<xslt in="${tmp}/${filename}/decompressedHdoc/content.xml" out="${out}/${filename}_data.xml" style="${xsl}/transformation.xsl" processor="org.apache.tools.ant.taskdefs.optional.TraXLiaison">
......@@ -56,6 +58,7 @@
<param name="lib" expression="${lib}"/>
</xslt>
<echo message="${filename}" />
</target>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:h="http://www.utc.fr/ics/hdoc/xhtml"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="h:html">
<xsl:apply-templates mode="title"></xsl:apply-templates>
</xsl:template>
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:h="http://www.utc.fr/ics/hdoc/xhtml"
exclude-result-prefixes="xs" version="2.0">
<xsl:template match="h:html">
<document>
<xsl:apply-templates mode="title"/>
</document>
</xsl:template>
<xsl:template match="h:head" mode="title">
<titre><xsl:value-of select="./h:title"/></titre>
<titre>
<xsl:value-of select="./h:title"/>
</titre>
<xsl:apply-templates select="./h:meta"/>
</xsl:template>
<xsl:template match="h:meta[@name='author']">
<authors>
<xsl:for-each select="tokenize(@content,', \d')">
<xsl:if test="position() = 1">
<xsl:for-each select="tokenize(.,', ')">
<author>
<xsl:value-of select="."/>
</author>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</authors>
</xsl:template>
<xsl:template match="h:body" mode="title">
</xsl:template>
<sections>
<xsl:apply-templates select="./h:section"/>
</sections>
</xsl:template>
<xsl:template match="h:section">
<section>
<titresection>
<xsl:value-of select="./h:header/h:h1"/>
</titresection>
<contenu>
<paragraphes>
<xsl:apply-templates select="h:div"/>
</paragraphes>
<xsl:apply-templates select="h:section" mode="soussect"/>
</contenu>
</section>
</xsl:template>
<xsl:template match="h:section" mode="soussect">
<soussection></soussection>
</xsl:template>
<xsl:template match="h:div" >
<xsl:if test="h:p">
<paragraphe>
<xsl:value-of select="."/>
</paragraphe>
</xsl:if>
<xsl:if test="h:ul">
<xsl:apply-templates select="h:ul"></xsl:apply-templates>
</xsl:if>
</xsl:template>
<xsl:template match="h:ul">
<xsl:for-each select="h:li">
<paragraphe>
<xsl:value-of select="h:p"/>
</paragraphe>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
</xsl:stylesheet>
......@@ -6,11 +6,11 @@
xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:param name="filename"/>
<xsl:strip-space elements="*"/>
<!-- This template matches the root. One hdoc file = one Canoprof's Programme" -->
<xsl:template match="h:html">
<sc:item xmlns:sc="http://www.utc.fr/ics/scenari/v3/core">
......@@ -20,7 +20,7 @@
</cp:program>
</sc:item>
</xsl:template>
<!-- Head related templates. -->
<xsl:template match="h:head">
<cp:programM>
......@@ -28,22 +28,22 @@
<sp:title>
<xsl:value-of select="./h:title"/>
</sp:title>
<!-- Hdoc's "date" = Programme's period. -->
<xsl:apply-templates select="./h:meta[@name='date']"/>
<!-- Hdoc's "description" = Programme's resume. -->
<xsl:apply-templates select="./h:meta[@name='description']"/>
</cp:programM>
</xsl:template>
<xsl:template match="h:head/h:meta[@name='date']">
<sp:period>
<xsl:value-of select="./@content"/>
</sp:period>
</xsl:template>
<xsl:template match="h:head/h:meta[@name='description']">
<sp:abstract>
<cp:txtDesc>
......@@ -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"/>