[2] | 1 | <?xml version="1.0" encoding="iso-8859-1"?> |
---|
| 2 | |
---|
| 3 | <!-- |
---|
| 4 | module : |
---|
| 5 | generation de la partie "nom" de l'id |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | source : |
---|
| 9 | /usr/home/fplod/incas/bibnemo/src/bibnemomaf/surname_id.xsl sur aedon.locean-ipsl.upmc.fr |
---|
| 10 | |
---|
| 11 | update: |
---|
| 12 | fplod 2007-05-18T13:03:39Z 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: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> |
---|