source: trunk/firstname_id.xsl @ 7

Last change on this file since 7 was 2, checked in by smasson, 17 years ago

initial import

File size: 2.9 KB
Line 
1<?xml version="1.0" encoding="iso-8859-1"?>
2
3<!--
4module :
5generation de la partie "prenom" de l'id
6
7source :
8/usr/home/fplod/incas/bibnemo/src/bibnemomaf/firstname_id.xsl sur aedon.locean-ipsl.upmc.fr
9
10update:
11fplod 2007-05-18T14:33:06Z aedon.locean-ipsl.upmc.fr (Darwin)
12creation
13cf http://www.dpawson.co.uk/xsl/sect2/N7998.html
14There's a trick to this:
15
16translate($x, translate($x, 'abcde', ''), '')
17
18will remove all characters except a,b,c,d, and e from your string $x.
19et String split into elements dans http://www.dpawson.co.uk/xsl/sect2/N7240.html
20http://www.dpawson.co.uk/xsl/sect2/N7240.html
21cf. http://www.dpawson.co.uk/xsl/sect2/N7240.html CRLF to BR
22-->
23
24<xsl:stylesheet
25 id="id" version="1.0"
26 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
27
28<xsl:template name="firstname_id">
29 <xsl:param name="firstname"/>
30 <xsl:choose>
31  <xsl:when test="contains($firstname ,' ')">
32   <xsl:call-template name="space_firstname" >
33    <xsl:with-param name="text" select="$firstname"/>
34   </xsl:call-template>
35  </xsl:when>
36  <xsl:when test="contains($firstname ,'-')">
37   <xsl:call-template name="hyphen" >
38    <xsl:with-param name="text" select="$firstname"/>
39   </xsl:call-template>
40  </xsl:when>
41  <xsl:otherwise>
42<xsl:value-of select="translate(substring($firstname,1,1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO','abcdefghijklmnopqrstuvwxyz éèçàùöñó')"/>
43  </xsl:otherwise>
44 </xsl:choose>
45</xsl:template>
46
47<xsl:template name="space_firstname">
48 <xsl:param name="text"/>
49 <xsl:choose>
50   <xsl:when test="contains($text, ' ')">
51   <xsl:variable name="transform">
52<xsl:value-of select="translate(substring(substring-before($text, ' '),1,1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO','abcdefghijklmnopqrstuvwxyz éèçàùöñó')"/>
53   </xsl:variable>
54   <xsl:value-of select="$transform"/>
55     <xsl:text>_</xsl:text>
56     <xsl:call-template name="space_firstname">
57       <xsl:with-param name="text" select="substring-after($text,' ')"/>
58     </xsl:call-template>
59   </xsl:when>
60   <xsl:otherwise>
61           <xsl:value-of select="translate(substring($text,1,1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO','abcdefghijklmnopqrstuvwxyz éèçàùöñó')"/>
62   </xsl:otherwise>
63 </xsl:choose>
64</xsl:template>
65<xsl:template name="hyphen">
66 <xsl:param name="text"/>
67 <xsl:choose>
68   <xsl:when test="contains($text, '-')">
69   <xsl:variable name="transform">
70<xsl:value-of select="translate(substring(substring-before($text, '-'),1,1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO','abcdefghijklmnopqrstuvwxyz éèçàùöñó')"/>
71   </xsl:variable>
72   <xsl:value-of select="$transform"/>
73     <xsl:text>-</xsl:text>
74     <xsl:call-template name="hyphen">
75       <xsl:with-param name="text" select="substring-after($text,'-')"/>
76     </xsl:call-template>
77   </xsl:when>
78   <xsl:otherwise>
79           <xsl:value-of select="translate(substring($text,1,1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO','abcdefghijklmnopqrstuvwxyz éèçàùöñó')"/>
80   </xsl:otherwise>
81 </xsl:choose>
82</xsl:template>
83</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.