[2] | 1 | <?xml version="1.0" encoding="iso-8859-1"?> |
---|
[76] | 2 | <xsl:stylesheet |
---|
| 3 | version="1.0" |
---|
[56] | 4 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
---|
[2] | 5 | |
---|
| 6 | <!-- |
---|
| 7 | module : |
---|
| 8 | generation de la partie "prenom" de l'id |
---|
| 9 | |
---|
[76] | 10 | update : |
---|
[33] | 11 | $Id$ |
---|
[2] | 12 | fplod 2007-05-18T14:33:06Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 13 | creation |
---|
| 14 | cf http://www.dpawson.co.uk/xsl/sect2/N7998.html |
---|
| 15 | There's a trick to this: |
---|
| 16 | |
---|
| 17 | translate($x, translate($x, 'abcde', ''), '') |
---|
| 18 | |
---|
| 19 | will remove all characters except a,b,c,d, and e from your string $x. |
---|
| 20 | et String split into elements dans http://www.dpawson.co.uk/xsl/sect2/N7240.html |
---|
| 21 | http://www.dpawson.co.uk/xsl/sect2/N7240.html |
---|
| 22 | cf. 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> |
---|