source: trunk/surname_id.xsl @ 8

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

initial import

File size: 1.9 KB
Line 
1<?xml version="1.0" encoding="iso-8859-1"?>
2
3<!--
4module :
5generation de la partie "nom" de l'id
6
7
8source :
9/usr/home/fplod/incas/bibnemo/src/bibnemomaf/surname_id.xsl sur aedon.locean-ipsl.upmc.fr
10
11update:
12fplod 2007-05-18T13:03:39Z 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:stylesheet
26 id="id" version="1.0"
27 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
28
29<xsl:template name="surname_id">
30 <xsl:param name="surname"/>
31 <xsl:choose>
32  <xsl:when test="contains($surname ,' ')">
33   <xsl:call-template name="space_surname" >
34    <xsl:with-param name="text" select="$surname"/>
35   </xsl:call-template>
36  </xsl:when>
37  <xsl:otherwise>
38<xsl:value-of select="translate($surname, 'abcdefghijklmnopqrstuvwxyz éèçàùëöñó', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO')"/>
39  </xsl:otherwise>
40 </xsl:choose>
41</xsl:template>
42
43<xsl:template name="space_surname">
44 <xsl:param name="text"/>
45 <xsl:choose>
46   <xsl:when test="contains($text, ' ')">
47   <xsl:variable name="transform">
48<xsl:value-of select="translate(substring-before($text, ' '), 'abcdefghijklmnopqrstuvwxyz éèçàùëöñó', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO')"/>
49   </xsl:variable>
50   <xsl:value-of select="$transform"/>
51     <xsl:text>_</xsl:text>
52     <xsl:call-template name="space_surname">
53       <xsl:with-param name="text" select="substring-after($text,' ')"/>
54     </xsl:call-template>
55   </xsl:when>
56   <xsl:otherwise>
57           <xsl:value-of select="translate($text, 'abcdefghijklmnopqrstuvwxyz éèçàùëöñó', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_EECAUEONO')"/>
58   </xsl:otherwise>
59 </xsl:choose>
60</xsl:template>
61</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.