source: trunk/firstname_id.xsl @ 33

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

add Id in many headers; replace bibrefnemo.xml by biblio.xml

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