source: trunk/firstname_id.xsl @ 53

Last change on this file since 53 was 49, checked in by pinsard, 16 years ago

improvements of .xsl files headers

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