Skip to content
Snippets Groups Projects
Commit 0176d048 authored by VAN-KOTE ELSA's avatar VAN-KOTE ELSA
Browse files

ajout des fichiers xquery et bash de génération de fichiers rst

parent 0aa80204
Branches
1 merge request!15ajout des fichiers xquery et bash de génération de fichiers rst
#! /bin/sh
SRC=$1
DST=$2
for path in $SRC/*
do
filename=$(basename $path)
noext=${filename%.*}
jq '[.title, .page_blocks[].text]' $path > $DST/$noext.json
#echo "avec: " $filename " sans: "$noext
done
#! /bin/sh
SRC=$1
DST=$2
for path in $SRC/*
do
filename=$(basename $path)
noext=${filename%.*}
jq '[.title, .page_blocks[].text]' $path > $DST/$noext.txt
#echo "avec: " $filename " sans: "$noext
done
#! /bin/sh
# permet de récupérer les notices écrites dans le projet expatre
# l'esperluette à la fin (&) permet de lancer chaque curl indépendemment du suivant, et lance donc plusieurs processus à la fois
# c'est beaucoup BEAUCOUP plus rapide
for numpage in $(seq 76)
do
curl -s -L https://expatre.huma-num.fr/api/exhibit_pages/$numpage > notice$numpage.json&
done
let $docs := collection('json')
let $files := db:list-details('json')
for $file in $files
return
for $doc in $docs
let $filename := substring-before($file, '.')
let $xml := file:write ('/home/evk/Documents/PHUN/EXPATRE/json_notices/json_to_xml/toto', $file)
return 'toto'
<!-- Feuille de transformation XSLT qui permet de transformer les fichiers xml liés au projet EXPATRE en output compatible rst.
-->
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:xqdoc="http://www.xqdoc.org/1.0"
exclude-result-prefixes="tei xsl">
<xsl:output omit-xml-declaration="yes" method="xml" encoding="utf-8" />
<xsl:template match="/">
<div><xsl:text>
</xsl:text>
<xsl:text>:orphan:
.. index::
single: </xsl:text><xsl:value-of select="//slug"/><xsl:text>
.. _</xsl:text><xsl:value-of select="//slug"/>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="//title"/>
<xsl:apply-templates select="//page__blocks"/>
</div>
</xsl:template>
<xsl:template match="exhibit | id | order | page__blocks//layout | page__blocks//options | page__blocks//page__id"/>
<xsl:template match="page__blocks">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="//attachments">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="h4 | em | strong">
<xsl:if test="not(string)"/>
<xsl:if test=". != ''">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<xsl:template match="em">
<xsl:choose>
<xsl:when test="./ancestor::h4/parent::text/preceding-sibling::order='1'">
<xsl:apply-templates/>
</xsl:when>
<xsl:when test="./ancestor::h4/following-sibling::p/strong">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:text>*</xsl:text><xsl:apply-templates/><xsl:text>*</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="strong">
<xsl:choose>
<xsl:when test="contains(., 'Bibliographie')">
<xsl:apply-templates/>
<xsl:text>
--------------</xsl:text>
</xsl:when>
<xsl:when test="ancestor::h4"><xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:text>**</xsl:text>
<xsl:apply-templates/>
<xsl:text>**</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="a">
<xsl:value-of select="concat(':ref:`', ., '`')"/>
</xsl:template>
<xsl:template match="title">
<xsl:text>
</xsl:text>
<xsl:text>===============</xsl:text><xsl:text>
</xsl:text>
<xsl:apply-templates/><xsl:text>
</xsl:text>
<xsl:text>===============</xsl:text><xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="h4">
<xsl:choose>
<xsl:when test=".//following-sibling::br">
<xsl:text>**Auteur : </xsl:text><xsl:apply-templates/><xsl:text>**</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text">
<xsl:choose>
<xsl:when test="./preceding-sibling::order = '2'">
<xsl:text>
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="p">
<xsl:choose>
<xsl:when test=". = ''"/>
<xsl:when test=".//preceding-sibling::p/strong='Bibliographie'">
<xsl:text>* </xsl:text>
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise></xsl:choose>
</xsl:template>
<xsl:template match="br">
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="sup"/>
</xsl:stylesheet>
\ No newline at end of file
declare function local:expatre_rst($entity){
let $xml := doc('json/'||$entity||'.json')
let $temp := file:write('temp/'||$entity||'.xml', $xml)
return $xml};
declare function local:create_csv($data, $path){
array:for-each(
$data,
function($line) {
file:append-text-lines($path, string-join($line,', '))
})
};
let $docs := db:list('json')
let $array_doc := array {
for $doc in $docs
(: on retire la définition de l'extension:)
let $name := substring-before($doc, '.')
return $name
}
let $result :=
array:for-each(
$array_doc,
function($filename) {
local:expatre_rst($filename)
})
return $result
declare function local:expatre_rst($entity){
let $xml := doc('temp/'||$entity||'.xml')
let $xslt := doc('/home/evk/Documents/PHUN/EXPATRE/json_notices/json_to_xml.xsl')
let $result := xslt:transform($xml, $xslt)
let $file := file:write('/home/evk/Documents/PHUN/EXPATRE/json_notices/rst/'||$entity||'.rst', $result)
return $result};
let $docs := db:list('temp')
let $array_doc := array {
for $doc in $docs
(: on retire la définition de l'extension:)
let $name := substring-before($doc, '.')
return $name
}
let $rst_files :=
array:for-each(
$array_doc,
function($filename) {
local:expatre_rst($filename)
})
return $rst_files
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