Templates (diple.xsl
© 2010–2011, École nationale des chartes, licence CeCILL-C/LGPL )- [FG] Frédéric Glorieux
- [VJ] Vincent Jolivet
Fichier de messages pour étiquettes générées.
$messages="tei.rdfs"Langue des messages (pour l'instant seul fr est implémenté) — cf. [tlabel]
$lang="fr"Date de génération, modifiable à l'appel. — cf. [thtml]
$date
2011
$xslBase
$corpusId=/*/@xml:id
Paramètre de titre de livre, utilisé en préfixe d'identifiant
$bookId$dipleHref
../
http://subversion.cru.fr/diple/trunk/
$theme=
Surchargeable si lien css différent de corpus.css — cf. [thtml]
$css
theme/neutre/diple.css
charger le fichier de messages, document('') permet de résoudre les chemin relativement à ce fichier — cf. [tlabel]
$rdf:Property=document($messages, document(''))/*/rdf:PropertyUne barre d'espaces insécables, utilisable pour de l'indentation automatique
$nbsp=" "pour conversion
$ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"$abc="abcdefghijklmnopqrstuvwxyz"
$apos="'"
$quote="""
document()$messages
mode="label" (titre court)
Le mode label génère un intitulé court obtenu par une liste de valeurs localisés (./tei.rdfs).
source
- <xsl:template name="
label
"> -
- <xsl:choose>
-
- <xsl:when test="$rdf:Property[@xml:id = $id]/rdfs:label[@xml:lang = $lang]">
-
<xsl:copy-of select="$rdf:Property[@xml:id = $id]/rdfs:label[@xml:lang = $lang]/node()"/>
- </xsl:when>
- <xsl:when test="
$rdf:Property[@xml:id = $id]/rdfs:label
"> -
<xsl:copy-of select="
$rdf:Property[@xml:id = $id]/rdfs:label[1]/node()
"/> - </xsl:when>
- <xsl:otherwise>
-
<xsl:value-of select="
$id
"/> - </xsl:otherwise>
- <xsl:when test="
- </xsl:choose>
- </xsl:template>
$rdf:Property[@xml:id = $id]/rdfs:label[@xml:lang = $lang]/node(), $rdf:Property[@xml:id = $id]/rdfs:label[1]/node(), $id
- $id :
source
<xsl:template match="/
" xml:space="preserve
" name="html
"></xsl:template>
<-- <xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">]]> </xsl:text> --><html> <head> <meta http-equiv="Content-type
" content="text/html; charset=UTF-8
"/> <meta name="modified
" content="{$date}
"/> <xsl:choose xml:space="default
"> <xsl:when test="$theme != ''
"> <link rel="stylesheet
" type="text/css
" href="{$theme}html.css"/> <link rel="stylesheet
" type="text/css
" href="{$theme}diple_html.css"/> <link rel="stylesheet
" type="text/css
" href="{$theme}{$corpusId}.css"/> </xsl:when> <xsl:when test="normalize-space($css) != ''
"> <link rel="stylesheet
" type="text/css
" media="screen
" href="{$css}"/> </xsl:when> </xsl:choose> <script type="text/javascript
" src="{$dipleHref}js/Tree.js
">//</script> <xsl:call-template name="head
"/> </head> <body class="{$corpusId} fixed
"> <div id="nav
" class="nav
"> <xsl:call-template name="nav
"/> </div> <div id="article
" class="article
"> <xsl:apply-templates/> </div> </body> <xsl:call-template name="bottom_script
"/> </html>
<body>, <div>, <head>, <html>, <link>, <meta>, <script>, "//"
Racine, créer un document HTML par défaut.source
<xsl:template name="
head
"/>source
<xsl:template name="
bottom_script
"/>source
- <xsl:template name="
xslBase
"> -
- <xsl:choose>
-
- <xsl:when test="
">
-
- <xsl:call-template name="
xslBase
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
">
-
- <xsl:call-template name="
xslBase
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
contains($path, '/')
"> -
<xsl:value-of select="
substring-before($path, '/')
"/>- <xsl:call-template name="
xslBase
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
- </xsl:choose>
- </xsl:template>
"/", substring-before($path, '/')
- $path :
source
- <xsl:template match="
*
"> -
- <div>
-
<xsl:call-template name="
tag
"/>- <b style="
color:red
"> -
<xsl:value-of select="
name()
"/> - </b>
- <b style="
- </div>
- </xsl:template>
<b>, <div>, "</", ">", name()
<*>, modèle par défaut d'interception des éléments non pris en chargesource
- <xsl:template name="
tag
"> -
- <b style="
color:red
"> -
<xsl:value-of select="
name()
"/>- <xsl:for-each select="
@*
"> -
<xsl:text/><xsl:value-of select="
name()
"/><xsl:value-of select=".
"/> - </xsl:for-each>
- <xsl:for-each select="
- </b>
- <b style="
- </xsl:template>
<b>, "<", "="", """, ">", name(), name(), .
Utile au déboguage, affichage de l'élément en courssource
- <xsl:template name="
string-replace-all
"> -
<xsl:param name="
text
"/><xsl:param name="replace
"/><xsl:param name="by
"/>- <xsl:choose>
-
- <xsl:when test="
contains($text,$replace)
"> -
<xsl:value-of select="
substring-before($text,$replace)
"/><xsl:value-of select="$by
"/>- <xsl:call-template name="
string-replace-all
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:otherwise>
-
<xsl:value-of select="
$text
"/> - </xsl:otherwise>
- <xsl:when test="
- </xsl:choose>
- </xsl:template>
substring-before($text,$replace), $by, $text
- $text :
- $replace :
- $by :
source
- <xsl:template name="
nb_mois
"> - </xsl:template>
"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"
- $le-mois :
source
- <xsl:template name="
date
"> -
<!--
arondir dates inventées
-->- <xsl:choose>
-
<!--
déjà des attributs
-->- <xsl:when test="
@notBefore and @notAfter and @notAfter=@notBefore
"> -
- <xsl:attribute name="
when
"> -
<xsl:value-of select="
@notAfter
"/> - </xsl:attribute>
- <xsl:attribute name="
- </xsl:when>
<!--notBefore="1200-09-01" notAfter="1200-09-30"
-->- <xsl:when test="substring(@notBefore, 8, 3) = '-01' and contains('-30-31-28', substring(@notAfter, 8, 3))">
-
- <xsl:attribute name="
when
"> -
<xsl:value-of select="
substring(@notBefore, 1, 7)
"/> - </xsl:attribute>
- <xsl:attribute name="
- </xsl:when>
- <xsl:when test="
@notBefore|@notAfter|@when
"> -
<xsl:copy-of select="
@*
"/> - </xsl:when>
<!--deux dates, problème
--><xsl:when test="contains(., ')(')
"><!--</xsl:when>xsl:message>Acte <xsl:value-of select="ancestor::text[1]/@n"/>, 2 dates <xsl:value-of select="."/></xsl:message
--><!--que des chiffres, année ?
-->- <xsl:when test="
translate(., '()1234567890.', '') = ''
"> -
- <xsl:attribute name="
when
"> -
<xsl:value-of select="
translate(., '(). ', '')
"/> - </xsl:attribute>
- <xsl:attribute name="
- </xsl:when>
<!--date simple
-->- <xsl:when test="
starts-with(., '(Vers')
"> -
- <xsl:attribute name="
when
"> -
<xsl:value-of select="
translate(., '(Vers) ', '')
"/> - </xsl:attribute>
- <xsl:attribute name="
- </xsl:when>
<!--date simple
-->- <xsl:when test="
starts-with(., '(Avant')
"> -
- <xsl:attribute name="
notAfter
"> -
<xsl:value-of select="
translate(., '(Avant) ', '')
"/> - </xsl:attribute>
- <xsl:attribute name="
- </xsl:when>
<!--date simple
-->- <xsl:when test="
starts-with(., '(Après')
"> -
- <xsl:attribute name="
notBefore
"> -
<xsl:value-of select="
translate(., '(Après) ', '')
"/> - </xsl:attribute>
- <xsl:attribute name="
- </xsl:when>
<!--période
-->- <xsl:when test="
starts-with(., '(Entre')
"> -
- <xsl:attribute name="
notBefore
"> -
<xsl:value-of select="substring-before(substring-after(., 'Entre '), ' ')"/>
- </xsl:attribute>
- <xsl:attribute name="
notAfter
"> -
<xsl:value-of select="translate( substring-before(substring-after(., 'et '), ')') , '(). ', '')"/>
- </xsl:attribute>
- <xsl:attribute name="
- </xsl:when>
<!--cas non pris en compte, à remplir ensuite
--><xsl:otherwise><!--</xsl:otherwise>xsl:message>Acte <xsl:value-of select="ancestor::text[1]/@n"/>, date non prise en charge <xsl:value-of select="."/></xsl:message
--> - <xsl:when test="
- </xsl:choose>
- </xsl:template>
@when, @*, @notAfter, substring(@notBefore, 1, 7), translate(., '(). ', ''), translate(., '(Vers) ', ''), translate(., '(Avant) ', ''), translate(., '(Après) ', ''), substring-before(substring-after(., 'Entre '), ' '), translate( substring-before(substring-after(., 'et '), ')') , '(). ', '')
attribut de dates en fonctions de la valeur courant, dégrossi le travail, mais du reste à faire
source
- <xsl:template name="
idpath
"> -
- <xsl:for-each select="
ancestor-or-self::*
"> -
<xsl:value-of select="
name()
"/><xsl:number/> - </xsl:for-each>
- <xsl:for-each select="
- </xsl:template>
"/", "[", "]", name()
Pour débogage afficher un pathsource
- <xsl:template name="
rom2int
"> -
<xsl:param name="
rom
"/>- <xsl:choose>
-
- <xsl:when test="
normalize-space($rom) = ''
"> -
<xsl:value-of select="
$int
"/> - </xsl:when>
- <xsl:when test="
starts-with($rom,'XC')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'IC')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'XL')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'L')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'C')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'D')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'M')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'IV')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'IX')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'IIX')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'I')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'V')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:when test="
starts-with($rom,'X')
"> -
- <xsl:call-template name="
rom2int
"> - </xsl:call-template>
- <xsl:call-template name="
- </xsl:when>
- <xsl:otherwise>
-
<xsl:value-of select="
$int
"/> - </xsl:otherwise>
- <xsl:when test="
- </xsl:choose>
- </xsl:template>
$int, $int
- $rom :
- $int :
source
- <xsl:template name="
dot
"> - </xsl:template>
". "
- $current :
au cas où le type est après le href
-->