source: trunk/firstname_id.xsl @ 140

Last change on this file since 140 was 76, checked in by pinsard, 16 years ago

no more NEMO reference in XSL files; project information (name and home page are in main.xml

  • Property svn:keywords set to Id
File size: 2.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 :
8generation de la partie "prenom" de l'id
9
10update :
11$Id$
12fplod 2007-05-18T14:33:06Z 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="firstname_id">
26 <xsl:param name="firstname"/>
27 <xsl:choose>
28  <xsl:when test="contains($firstname ,' ')">
29   <xsl:call-template name="space_firstname" >
30    <xsl:with-param name="text" select="$firstname"/>
31   </xsl:call-template>
32  </xsl:when>
33  <xsl:when test="contains($firstname ,'-')">
34   <xsl:call-template name="hyphen" >
35    <xsl:with-param name="text" select="$firstname"/>
36   </xsl:call-template>
37  </xsl:when>
38  <xsl:otherwise>
39<xsl:value-of select="translate(substring($firstname,1,1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO','abcdefghijklmnopqrstuvwxyz éèçàùöñó')"/>
40  </xsl:otherwise>
41 </xsl:choose>
42</xsl:template>
43
44<xsl:template name="space_firstname">
45 <xsl:param name="text"/>
46 <xsl:choose>
47   <xsl:when test="contains($text, ' ')">
48   <xsl:variable name="transform">
49<xsl:value-of select="translate(substring(substring-before($text, ' '),1,1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO','abcdefghijklmnopqrstuvwxyz éèçàùöñó')"/>
50   </xsl:variable>
51   <xsl:value-of select="$transform"/>
52     <xsl:text>_</xsl:text>
53     <xsl:call-template name="space_firstname">
54       <xsl:with-param name="text" select="substring-after($text,' ')"/>
55     </xsl:call-template>
56   </xsl:when>
57   <xsl:otherwise>
58           <xsl:value-of select="translate(substring($text,1,1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO','abcdefghijklmnopqrstuvwxyz éèçàùöñó')"/>
59   </xsl:otherwise>
60 </xsl:choose>
61</xsl:template>
62<xsl:template name="hyphen">
63 <xsl:param name="text"/>
64 <xsl:choose>
65   <xsl:when test="contains($text, '-')">
66   <xsl:variable name="transform">
67<xsl:value-of select="translate(substring(substring-before($text, '-'),1,1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO','abcdefghijklmnopqrstuvwxyz éèçàùöñó')"/>
68   </xsl:variable>
69   <xsl:value-of select="$transform"/>
70     <xsl:text>-</xsl:text>
71     <xsl:call-template name="hyphen">
72       <xsl:with-param name="text" select="substring-after($text,'-')"/>
73     </xsl:call-template>
74   </xsl:when>
75   <xsl:otherwise>
76           <xsl:value-of select="translate(substring($text,1,1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO','abcdefghijklmnopqrstuvwxyz éèçàùöñó')"/>
77   </xsl:otherwise>
78 </xsl:choose>
79</xsl:template>
80</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.