source: trunk/firstname_id.xsl

Last change on this file was 323, checked in by pinsard, 11 years ago

fix for XSL documentations

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