source: trunk/surname_id.xsl @ 59

Last change on this file since 59 was 56, checked in by pinsard, 16 years ago

migration to docbook5 for biblio.xml; bug fix in bibopa.sh; xmlto is not anymore needed; xml(starlet) must be available

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1<?xml version="1.0" encoding="iso-8859-1"?>
2<xsl:stylesheet
3version="1.0"
4xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
6<!--
7module :
8génération de la partie "nom" de l'id
9
10update :
11$Id$
12fplod 2007-05-18T13:03:39Z aedon.locean-ipsl.upmc.fr (Darwin)
13creation
14cf http://www.dpawson.co.uk/xsl/sect2/N7998.html
15There's a trick to this:
16
17translate($x, translate($x, 'abcde', ''), '')
18
19will remove all characters except a,b,c,d, and e from your string $x.
20et String split into elements dans http://www.dpawson.co.uk/xsl/sect2/N7240.html
21http://www.dpawson.co.uk/xsl/sect2/N7240.html
22cf. http://www.dpawson.co.uk/xsl/sect2/N7240.html CRLF to BR
23-->
24
25<xsl:template name="surname_id">
26 <xsl:param name="surname"/>
27 <xsl:choose>
28  <xsl:when test="contains($surname ,' ')">
29   <xsl:call-template name="space_surname" >
30    <xsl:with-param name="text" select="$surname"/>
31   </xsl:call-template>
32  </xsl:when>
33  <xsl:otherwise>
34<xsl:value-of select="translate($surname, 'abcdefghijklmnopqrstuvwxyz éèçàùëöñó', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO')"/>
35  </xsl:otherwise>
36 </xsl:choose>
37</xsl:template>
38
39<xsl:template name="space_surname">
40 <xsl:param name="text"/>
41 <xsl:choose>
42   <xsl:when test="contains($text, ' ')">
43   <xsl:variable name="transform">
44<xsl:value-of select="translate(substring-before($text, ' '), 'abcdefghijklmnopqrstuvwxyz éèçàùëöñó', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO')"/>
45   </xsl:variable>
46   <xsl:value-of select="$transform"/>
47     <xsl:text>_</xsl:text>
48     <xsl:call-template name="space_surname">
49       <xsl:with-param name="text" select="substring-after($text,' ')"/>
50     </xsl:call-template>
51   </xsl:when>
52   <xsl:otherwise>
53           <xsl:value-of select="translate($text, 'abcdefghijklmnopqrstuvwxyz éèçàùëöñó', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO')"/>
54   </xsl:otherwise>
55 </xsl:choose>
56</xsl:template>
57</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.