Commit b40a2573 authored by Stephane Crozat's avatar Stephane Crozat

Ajout d'un XSLT pour gérer l'export du catalogue en SQL et d'un COPY pour l'export des en CSV

parent afe270ac
ADD catalogue.website
<?xml-stylesheet href="export_sql.xsl" type="text/xsl"?>
\COPY (SELECT * FROM vApi) TO 'api.csv' CSV HEADER DELIMITER ';'
<?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:of="scpf.org:office"
>
<xsl:output method="text"></xsl:output>
<xsl:template match="/sc:item">
<xsl:text>INSERT INTO api (code,name,year,semester,dbegin,dend,size,ects) VALUES</xsl:text>
<xsl:apply-templates select="of:webSite/sp:home/of:page/sp:subPage"/>
;
</xsl:template>
<xsl:template match="sp:subPage">
<xsl:apply-templates select="document(@sc:refUri)/sc:item" mode="api">
<xsl:with-param name="code">
<xsl:value-of select="substring(@sc:refUri,string-length(@sc:refUri)-11,4)"/>
</xsl:with-param>
</xsl:apply-templates>
<xsl:if test="following::sp:subPage">,</xsl:if>
</xsl:template>
<xsl:template match="sc:item" mode="api">
<xsl:param name="code"/>
<xsl:variable name="title">
<xsl:variable name="quote">'</xsl:variable>
<xsl:value-of select="replace(of:section/of:sectionM/sp:title,'''','''''')"/>
</xsl:variable>
<xsl:variable name="begin">
<xsl:value-of select="substring(.//sp:info[of:block/of:blockM/sp:title='Période']//sc:para,1,5)"/>
</xsl:variable>
<xsl:variable name="end">
<xsl:value-of select="substring(.//sp:info[of:block/of:blockM/sp:title='Période']//sc:para,7,11)"/>
</xsl:variable>
<xsl:variable name="size">
<xsl:value-of select="number(.//sp:info[of:block/of:blockM/sp:title='Capacité d''accueil']//sc:para)"/>
</xsl:variable>
<xsl:variable name="ects">
<xsl:value-of select="number(.//sp:info[of:block/of:blockM/sp:title='ECTS']//sc:para)"/>
</xsl:variable>
(
<xsl:value-of select="$code"/>,
'<xsl:value-of select="substring($title,8)"></xsl:value-of>',
2019,
'H',
TO_DATE('<xsl:value-of select="$begin"/>/19','DD/MM/YY'),
TO_DATE('<xsl:value-of select="$end"/>/19','DD/MM/YY'),
<xsl:value-of select="$size"/>,
<xsl:value-of select="$ects"/>
)
</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