Skip to content

Instantly share code, notes, and snippets.

@vdcrea
Created July 20, 2015 17:08
Show Gist options
  • Save vdcrea/536a362c12b6e5c34290 to your computer and use it in GitHub Desktop.
Save vdcrea/536a362c12b6e5c34290 to your computer and use it in GitHub Desktop.
xsl file to output xml used for unsa-industrie.org
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xls="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:string="http://www.getsymphony.com/functions"
exclude-result-prefixes="xls string">
<xsl:import href="../utilities/functions/function.string.utilities.xsl"/>
<xsl:output method="xml"
omit-xml-declaration="yes"
encoding="UTF-8"
indent="yes" />
<!-- Keys for branches, syndicats and sections view -->
<xsl:key name="branches" match="xls:Row"
use="xls:Cell[position()=1]"/>
<xsl:key name="sections-by-branche" match="xls:Row"
use="concat(xls:Cell[position()=1], '|', xls:Cell[position()=3])"/>
<xsl:key name="sections-by-branche-by-syndicat" match="xls:Row"
use="concat(xls:Cell[position()=1], '|', xls:Cell[position()=3], '|', xls:Cell[position()=2])"/>
<xsl:key name="syndicats" match="xls:Row"
use="xls:Cell[position()=2]"/>
<xsl:key name="branches-by-syndicat" match="xls:Row"
use="concat(xls:Cell[position()=2], '|', xls:Cell[position()=1])"/>
<xsl:key name="sections-by-syndicat" match="xls:Row"
use="concat(xls:Cell[position()=2], '|', xls:Cell[position()=3])"/>
<xsl:key name="sections" match="xls:Row"
use="xls:Cell[position()=3]"/>
<xsl:key name="sections-by-syndicat" match="xls:Row"
use="concat(xls:Cell[position()=3], '|', xls:Cell[position()=2])"/>
<!-- Keys for contact view -->
<xsl:key name="etablissements-by-syndicat" match="xls:Row"
use="xls:Cell[position()=2]"/>
<xsl:key name="etablissements-by-syndicat-by-city" match="xls:Row"
use="concat(xls:Cell[position()=2], '|', xls:Cell[position()=4])"/>
<xsl:key name="contacts-by-syndicat-by-city" match="xls:Row"
use="concat(xls:Cell[position()=2], '|', xls:Cell[position()=4], '|', xls:Cell[position()=5])"/>
<xsl:key name="etablissements-by-section" match="xls:Row"
use="xls:Cell[position()=3]"/>
<xsl:key name="etablissements-by-section-by-city" match="xls:Row"
use="concat(xls:Cell[position()=3], '|', xls:Cell[position()=4])"/>
<xsl:key name="contacts-by-section-by-city" match="xls:Row"
use="concat(xls:Cell[position()=3], '|', xls:Cell[position()=4], '|', xls:Cell[position()=5])"/>
<xsl:key name="etablissements-by-city" match="xls:Row"
use="xls:Cell[position()=4]"/>
<xsl:key name="contacts-by-city" match="xls:Row"
use="concat(xls:Cell[position()=4], '|', xls:Cell[position()=5])"/>
<!-- Keys for tree view -->
<xsl:key name="branche" match="xls:Row"
use="xls:Cell[position()=1]"/>
<xsl:key name="syndicat" match="xls:Row"
use="concat(xls:Cell[position()=1], '|', xls:Cell[position()=2])"/>
<xsl:key name="section" match="xls:Row"
use="concat(xls:Cell[position()=1], '|', xls:Cell[position()=2], '|', xls:Cell[position()=3])"/>
<xsl:key name="etablissement" match="xls:Row"
use="concat(xls:Cell[position()=1], '|', xls:Cell[position()=2], '|', xls:Cell[position()=3], '|', xls:Cell[position()=4])"/>
<xsl:template match="/">
<xsl:variable name="filter"><xsl:choose><xsl:when test="$filtertype!=''"><xsl:value-of select="$filtervalue"/></xsl:when><xsl:otherwise><xsl:value-of select="$website-name"/></xsl:otherwise></xsl:choose></xsl:variable>
<xsl:choose>
<!-- Branches -->
<xsl:when test="$request='branches'">
<branches name="{$filter}">
<xsl:choose>
<xsl:when test="$filtertype='syndicat'">
<xsl:apply-templates select="//xls:Row[position()&gt;1][generate-id() = generate-id(key('syndicats', xls:Cell[position()=2])[1])]" mode="branches-by-syndicat"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="//xls:Row[position()&gt;1][generate-id() = generate-id(key('branches', xls:Cell[position()=1])[1])]" mode="branches"/>
</xsl:otherwise>
</xsl:choose>
</branches>
</xsl:when>
<!-- Syndicats -->
<xsl:when test="$request='syndicats'">
<syndicats name="{$filter}">
<xsl:apply-templates select="//xls:Row[position()&gt;1][generate-id() = generate-id(key('syndicats', xls:Cell[position()=2])[1])]" mode="syndicats"/>
</syndicats>
</xsl:when>
<!-- Sections -->
<xsl:when test="$request='sections'">
<sections name="{$filter}">
<xsl:choose>
<xsl:when test="$filtertype='branche'">
<xsl:apply-templates select="//xls:Row[position()&gt;1][generate-id() = generate-id(key('branches', xls:Cell[position()=1])[1])]" mode="sections-by-branche"/>
</xsl:when>
<xsl:when test="$filtertype='syndicat'">
<xsl:apply-templates select="//xls:Row[position()&gt;1][generate-id() = generate-id(key('syndicats', xls:Cell[position()=2])[1])]" mode="sections-by-syndicat"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="//xls:Row[position()&gt;1][generate-id() = generate-id(key('sections', xls:Cell[position()=3])[1])]" mode="sections"/>
</xsl:otherwise>
</xsl:choose>
</sections>
</xsl:when>
<xsl:when test="$request='etablissements'">
<contacts name="{$filter}">
<xsl:choose>
<xsl:when test="$filtertype='syndicat'">
<xsl:apply-templates select="//xls:Row[position()&gt;1][generate-id() = generate-id(key('etablissements-by-syndicat', xls:Cell[position()=2])[1])]" mode="etablissements-by-syndicat"/>
</xsl:when>
<xsl:when test="$filtertype='section'">
<xsl:apply-templates select="//xls:Row[position()&gt;1][generate-id() = generate-id(key('etablissements-by-section', xls:Cell[position()=3])[1])]" mode="etablissements-by-section"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="//xls:Row[position()&gt;1][generate-id() = generate-id(key('etablissements-by-city', xls:Cell[position()=4])[1])]" mode="etablissements-by-city"/>
</xsl:otherwise>
</xsl:choose>
</contacts>
</xsl:when>
<!-- Tree -->
<xsl:when test="$request='tree'">
<xsl:choose>
<xsl:when test="$filtertype=''">
<tree name="{$filter}">
<xsl:for-each select="data/xml-branches/secteur">
<secteur name="{@value}">
<xsl:for-each select="entry">
<xsl:variable name="branche" select="nom"/>
<xsl:apply-templates select="//xml-file/xls:Table/xls:Row[xls:Cell[position()=1]=$branche][generate-id() = generate-id(key('branche', xls:Cell)[1])]" mode="branche"/>
</xsl:for-each>
</secteur>
</xsl:for-each>
</tree>
</xsl:when>
<xsl:otherwise>
<tree name="{$filter}">
<xsl:apply-templates select="data/xml-file/xls:Table/xls:Row[position()&gt;1][generate-id() = generate-id(key('branche', xls:Cell)[1])]" mode="branche"/>
</tree>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Admin Email -->
<xsl:when test="$request='admin'">
<admin id="{$filter}">
<xsl:choose>
<xsl:when test="$filtertype='email'">
<xsl:for-each select="//xls:Row[xls:Cell[position()=6]=$filtervalue]">
<xsl:variable name="syndicat-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=2]"/></xsl:call-template></xsl:variable>
<xsl:variable name="section-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=3]"/></xsl:call-template></xsl:variable>
<xsl:variable name="branche-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=1]"/></xsl:call-template></xsl:variable>
<etablissement branche-handle="{$branche-handle}" syndicat="{xls:Cell[position()=2]}" syndicat-handle="{$syndicat-handle}" section="{xls:Cell[position()=3]}" section-handle="{$section-handle}" etablissement="{xls:Cell[position()=4]}" contact="{xls:Cell[position()=5]}" tel="{xls:Cell[position()=7]}"/>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</admin>
</xsl:when>
<!-- User guide -->
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$cookie-username='vincent'">
<how-to>
<request>Add a request</request>
<format url="{$root}/xml/request/filtertype/filtervalue"/>
<request name="branches" url="{$root}/xml/branches">
<filtertype name="syndicat" ex="{$root}/xml/branches/syndicat/unsa-industrie"/>
</request>
<request name="syndicats" url="{$root}/xml/syndicats">
<filtertype name="branche" ex="{$root}/xml/syndicats/branche/papier-carton"/>
</request>
<request name="etablissements" url="{$root}/xml/etablissements">
<filtertype name="syndicat" ex="{$root}/xml/etablissements/syndicat/unsa-metallurgie"/>
<filtertype name="section" ex="{$root}/xml/etablissements/section/safran"/>
</request>
<request name="tree" url="{$root}/xml/tree">
<filtertype name="branche" ex="{$root}/xml/tree/branche/metallurgie"/>
</request>
<request name="sections" url="{$root}/xml/sections">
<filtertype name="branche" ex="{$root}/xml/sections/branche/chimie"/>
<filtertype name="syndicat" ex="{$root}/xml/sections/syndicat/unsa-chimie"/>
</request>
<request name="admin" url="{$root}/xml/admin/email/[email protected]"/>
</how-to>
</xsl:when>
<xsl:otherwise>
<sorry>Private methods</sorry>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- BRANCHE VIEW TEMPLATE -->
<xsl:template match="xls:Row" mode="branches">
<xsl:variable name="branche-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=1]"/></xsl:call-template></xsl:variable>
<xsl:if test="($filtertype='')
or ($filtertype='branche' and $filtervalue=$branche-handle)">
<branche name="{xls:Cell[position()=1]}" handle="{$branche-handle}"/>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="branches-by-syndicat">
<xsl:apply-templates select="
key('syndicats', xls:Cell[position()=2])[generate-id() = generate-id(
key('branches-by-syndicat',
concat(xls:Cell[position()=2], '|', xls:Cell[position()=1]))[1])]" mode="branche-by-syndicat"/>
</xsl:template>
<xsl:template match="xls:Row" mode="branche-by-syndicat">
<xsl:variable name="branche-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=1]"/></xsl:call-template></xsl:variable>
<xsl:variable name="syndicat-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=2]"/></xsl:call-template></xsl:variable>
<xsl:if test="$filtervalue=$syndicat-handle">
<branche name="{xls:Cell[position()=1]}" handle="{$branche-handle}"/>
</xsl:if>
</xsl:template>
<!-- ETABLISSEMENTS VIEW TEMPLATE -->
<xsl:template match="xls:Row" mode="etablissements-by-city">
<xsl:if test="xls:Cell[position()=4]!='no'">
<ville name="{xls:Cell[position()=4]}">
<xsl:apply-templates select="
key('etablissements-by-city', xls:Cell[position()=4])[generate-id() = generate-id(
key('contacts-by-city', concat(xls:Cell[position()=4], '|', xls:Cell[position()=5]))[1])]" mode="etablissement"/>
</ville>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="etablissements-by-syndicat">
<xsl:if test="xls:Cell[position()=4]!='no'">
<xsl:variable name="syndicat-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=2]"/></xsl:call-template></xsl:variable>
<xsl:if test="$filtervalue=$syndicat-handle">
<xsl:apply-templates select="
key('etablissements-by-syndicat', xls:Cell[position()=2])[generate-id() = generate-id(
key('etablissements-by-syndicat-by-city', concat(xls:Cell[position()=2], '|', xls:Cell[position()=4]))[1])]" mode="contacts-by-syndicat-by-city"/>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="contacts-by-syndicat-by-city">
<xsl:if test="xls:Cell[position()=4]!='no'">
<xsl:variable name="syndicat-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=2]"/></xsl:call-template></xsl:variable>
<xsl:if test="$filtervalue=$syndicat-handle">
<ville name="{xls:Cell[position()=4]}">
<xsl:apply-templates select="
key('etablissements-by-syndicat-by-city', concat(xls:Cell[position()=2], '|', xls:Cell[position()=4]))[generate-id() = generate-id(
key('contacts-by-syndicat-by-city', concat(xls:Cell[position()=2], '|', xls:Cell[position()=4], '|', xls:Cell[position()=5]))[1])]" mode="etablissement"/>
</ville>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="etablissements-by-section">
<xsl:if test="xls:Cell[position()=4]!='no'">
<xsl:variable name="section-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=3]"/></xsl:call-template></xsl:variable>
<xsl:if test="$filtervalue=$section-handle">
<xsl:apply-templates select="
key('etablissements-by-section', xls:Cell[position()=3])[generate-id() = generate-id(
key('etablissements-by-section-by-city', concat(xls:Cell[position()=3], '|', xls:Cell[position()=4]))[1])]" mode="contacts-by-section-by-city"/>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="contacts-by-section-by-city">
<xsl:if test="xls:Cell[position()=4]!='no'">
<xsl:variable name="section-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=3]"/></xsl:call-template></xsl:variable>
<xsl:if test="$filtervalue=$section-handle">
<ville name="{xls:Cell[position()=4]}">
<xsl:apply-templates select="
key('etablissements-by-section-by-city', concat(xls:Cell[position()=3], '|', xls:Cell[position()=4]))[generate-id() = generate-id(
key('contacts-by-section-by-city', concat(xls:Cell[position()=3], '|', xls:Cell[position()=4], '|', xls:Cell[position()=5]))[1])]" mode="etablissement"/>
</ville>
</xsl:if>
</xsl:if>
</xsl:template>
<!-- SYNDICAT VIEW TEMPLATE -->
<xsl:template match="xls:Row" mode="syndicats">
<xsl:variable name="branche-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=1]"/></xsl:call-template></xsl:variable>
<xsl:variable name="handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=2]"/></xsl:call-template></xsl:variable>
<xsl:if test="($filtertype='')
or ($filtertype='branche' and $filtervalue=$branche-handle)">
<syndicat name="{xls:Cell[position()=2]}" handle="{$handle}"/>
</xsl:if>
</xsl:template>
<!-- SECTIONS VIEW TEMPLATE -->
<xsl:template match="xls:Row" mode="sections">
<xsl:if test="xls:Cell[position()=3]!='no' and xls:Cell[position()=4]!='no'">
<xsl:variable name="section-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=3]"/></xsl:call-template></xsl:variable>
<entreprise name="{xls:Cell[position()=3]}" handle="{$section-handle}">
<xsl:apply-templates select="
key('sections', xls:Cell[position()=3])[generate-id() = generate-id(
key('sections-by-syndicat',
concat(xls:Cell[position()=3], '|', xls:Cell[position()=2]))[1])]" mode="section-syndicale"/>
</entreprise>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="sections-by-branche">
<xsl:if test="xls:Cell[position()=3]!='no' and xls:Cell[position()=4]!='no'">
<xsl:variable name="branche-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=1]"/></xsl:call-template></xsl:variable>
<xsl:if test="$filtervalue=$branche-handle">
<xsl:apply-templates select="
key('branches', xls:Cell[position()=1])[generate-id() = generate-id(
key('sections-by-branche',
concat(xls:Cell[position()=1], '|', xls:Cell[position()=3]))[1])]" mode="sections-by-branche-by-syndicat"/>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="sections-by-branche-by-syndicat">
<xsl:if test="xls:Cell[position()=3]!='no' and xls:Cell[position()=4]!='no'">
<xsl:variable name="branche-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=1]"/></xsl:call-template></xsl:variable>
<xsl:if test="$filtervalue=$branche-handle">
<xsl:variable name="section-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=3]"/></xsl:call-template></xsl:variable>
<entreprise name="{xls:Cell[position()=3]}" handle="{$section-handle}">
<xsl:apply-templates select="
key('sections-by-branche',
concat(xls:Cell[position()=1], '|', xls:Cell[position()=3]))[generate-id() = generate-id(
key('sections-by-branche-by-syndicat',
concat(xls:Cell[position()=1], '|', xls:Cell[position()=3], '|', xls:Cell[position()=2]))[1])]" mode="section-syndicale"/>
</entreprise>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="sections-by-syndicat">
<xsl:if test="xls:Cell[position()=3]!='no' and xls:Cell[position()=4]!='no'">
<xsl:variable name="syndicat-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=2]"/></xsl:call-template></xsl:variable>
<xsl:if test="$filtervalue=$syndicat-handle">
<xsl:apply-templates select="
key('syndicats', xls:Cell[position()=2])[generate-id() = generate-id(
key('sections-by-syndicat',
concat(xls:Cell[position()=2], '|', xls:Cell[position()=3]))[1])]" mode="section-syndicale"/>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="section-syndicale">
<xsl:if test="xls:Cell[position()=3]!='no' and xls:Cell[position()=4]!='no'">
<xsl:variable name="branche-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=1]"/></xsl:call-template></xsl:variable>
<xsl:variable name="syndicat-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=2]"/></xsl:call-template></xsl:variable>
<xsl:variable name="section-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=3]"/></xsl:call-template></xsl:variable>
<xsl:if test="($filtertype='')
or ($filtertype='branche' and $filtervalue=$branche-handle)
or ($filtertype='syndicat' and $filtervalue=$syndicat-handle)">
<section-syndicale name="{xls:Cell[position()=3]}" branche="{xls:Cell[position()=1]}" syndicat="{xls:Cell[position()=2]}" path="{$syndicat-handle}/{$section-handle}" />
</xsl:if>
</xsl:if>
</xsl:template>
<!-- TREE VIEW TEMPLATES -->
<xsl:template match="xls:Row" mode="branche">
<xsl:variable name="branche-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell"/></xsl:call-template></xsl:variable>
<xsl:variable name="syndicat-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=2]"/></xsl:call-template></xsl:variable>
<xsl:if test="($filtertype='')
or ($filtertype='branche' and $filtervalue=$branche-handle)
or ($filtertype='syndicat' and $filtervalue=$syndicat-handle)">
<branche name="{xls:Cell}" handle="{$branche-handle}">
<xsl:apply-templates select="
key('branche', xls:Cell[position()=1])[generate-id() = generate-id(
key('syndicat',
concat(xls:Cell[position()=1], '|', xls:Cell[position()=2]))[1])]" mode="syndicat"/>
</branche>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="syndicat">
<xsl:if test="xls:Cell[position()=3]!='no' and xls:Cell[position()=4]!='no'">
<xsl:variable name="branche-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell"/></xsl:call-template></xsl:variable>
<xsl:variable name="syndicat-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=2]"/></xsl:call-template></xsl:variable>
<xsl:if test="($filtertype='')
or ($filtertype='branche' and $filtervalue=$branche-handle)
or ($filtertype='syndicat' and $filtervalue=$syndicat-handle)">
<syndicat name="{xls:Cell[position()=2]}" path="{$syndicat-handle}">
<xsl:apply-templates select="
key('syndicat',
concat(xls:Cell[position()=1], '|', xls:Cell[position()=2]))[generate-id() = generate-id(
key('section',
concat(xls:Cell[position()=1], '|', xls:Cell[position()=2], '|', xls:Cell[position()=3]))[1])
]" mode="section"/>
</syndicat>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="section">
<xsl:if test="xls:Cell[position()=3]!='no' and xls:Cell[position()=4]!='no'">
<xsl:variable name="path"><xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=2]"/></xsl:call-template>/<xsl:call-template name="handle"><xsl:with-param name="string" select="xls:Cell[position()=3]"/></xsl:call-template></xsl:variable>
<xsl:choose>
<xsl:when test="$filtertype='section'">
<section name="{xls:Cell[position()=3]}" path="{$path}">
<xsl:apply-templates select="
key('section',
concat(xls:Cell[position()=1], '|', xls:Cell[position()=2], '|', xls:Cell[position()=3]))[generate-id() = generate-id(
key('etablissement',
concat(xls:Cell[position()=1], '|', xls:Cell[position()=2], '|', xls:Cell[position()=3], '|', xls:Cell[position()=4]))[1])
]" mode="etablissement"/>
</section>
</xsl:when>
<xsl:otherwise>
<section name="{xls:Cell[position()=3]}" path="{$path}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template match="xls:Row" mode="etablissement">
<xsl:call-template name="etablissement"/>
</xsl:template>
<!-- ETABLISSEMENT VIEW TEMPLATE -->
<xsl:template name="etablissement">
<xsl:if test="xls:Cell[position()=3]!='no' and xls:Cell[position()=4]!='no'">
<xsl:variable name="branche"><xsl:value-of select="xls:Cell[position()=1]"/></xsl:variable>
<xsl:variable name="syndicat"><xsl:value-of select="xls:Cell[position()=2]"/></xsl:variable>
<xsl:variable name="section"><xsl:value-of select="xls:Cell[position()=3]"/></xsl:variable>
<xsl:variable name="ville"><xsl:value-of select="xls:Cell[position()=4]"/></xsl:variable>
<xsl:variable name="branche-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="$branche"/></xsl:call-template></xsl:variable>
<xsl:variable name="syndicat-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="$syndicat"/></xsl:call-template></xsl:variable>
<xsl:variable name="section-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="$section"/></xsl:call-template></xsl:variable>
<xsl:variable name="ville-handle"><xsl:call-template name="handle"><xsl:with-param name="string" select="$ville"/></xsl:call-template></xsl:variable>
<xsl:variable name="path"><xsl:value-of select="$syndicat-handle"/>/<xsl:value-of select="$section-handle"/></xsl:variable>
<xsl:variable name="contact"><xsl:value-of select="xls:Cell[position()=5]"/></xsl:variable>
<xsl:variable name="mail"><xsl:value-of select="xls:Cell[position()=6]"/></xsl:variable>
<xsl:variable name="tel"><xsl:value-of select="xls:Cell[position()=7]"/></xsl:variable>
<xsl:if test="($filtertype='')
or ($filtertype='branche' and $filtervalue=$branche-handle)
or ($filtertype='syndicat' and $filtervalue=$syndicat-handle)
or ($filtertype='section' and $filtervalue=$section-handle)">
<etablissement branche="{$branche}" branche-handle="{$branche-handle}" syndicat="{$syndicat}" syndicat-handle="{$syndicat-handle}" section="{$section}" path="{$path}" etablissement="{$ville}" contact="{$contact}" mail="{$mail}" tel="{$tel}" />
</xsl:if>
</xsl:if>
</xsl:template>
<!-- UTILITY -->
<xsl:template name="handle">
<xsl:param name="string"/>
<xsl:variable name="apos">'</xsl:variable>
<xsl:variable name="virg">,</xsl:variable>
<xsl:variable name="strip"></xsl:variable>
<xsl:value-of select="
string:replace(
string:replace(
string:replace(
string:lower-case(string:sanitize($string))
,$apos,$strip)
,$virg,$strip)
,' ','-')"/>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment