<?xml version='1.0' encoding="UTF-8" ?>
<!--
 * NAT - An universal Translator
 * Copyright (C) 2005 Bruno Mascret
 * Contact: bmascret@free.fr
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-->
<!--STANDALONE version -->
<!-- how to use it?
1) with nat (http://natbraille.free.fr), you could directly test patterns and word in the gui interface:
go in "options (ctrl+o)", choose "Editer les règles" ( alt+r). Enter the word to try (text field shortcut: alt+m), validate "Tester" button (alt+t).
For details, activate the checkbox "détail" or use alt + d 

2) without nat:
- uncomment "nat:insert-char-if-not-digit" and "nat:insert-char" functions (l.60 and l.84); the whole library (nat-functs.xsl) is downloadable at http://natbraille.free.fr/xsl/
- uncomment "patterns variable"
- COMMENT line 46: xsl:include nat-functs.xsl
- create an xml document containing "word" tags, see for example http://natbraille.free.fr/xsl/testHyph.xml
- download nat-functs.xsl: most of the functions are not used in hyphenate ;-)
- apply stylesheet... something like "java -jar saxon9.jar -s:testHyph.xml -xsl:hyphenation.xsl"
-->

<xsl:stylesheet version="2.0"
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' 
xmlns:nat='http://natbraille.free.fr/xsl' 
xmlns:fn='http://www.w3.org/2005/xpath-functions'
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<!-- version: 1.0.1 -->
<xsl:output method="text" encoding="UTF-8" indent="no"/>
<xsl:param name="debug" as="xs:boolean" select="false()"/>

<!-- comment if standalone use -->
<!--<xsl:include href="nat-functs.xsl"/>-->

<!--<xsl:template match="/">
	<xsl:apply-templates/>
</xsl:template>-->


<!-- French patterns (dump of nat's hyphens.xsl with open office dictionary -->
<!-- uncomment if standalone use -->

<xsl:param name="patterns" as="xs:string*" select="tokenize('^a4,^ab3réa,^ae3s4ch,^amino1a2c,^ana3s4tr,^anti1a2,^anti1e2,^anti1s2,^anti1é2,^anti2enne,^apo2s3ta,^ar3dent$,^ar3gent$,^ar3pent$,^as2ta,^bai2se3main,^bi1a2c,^bi1a2t,^bi1au,^bi1u2,^bi2s1a2,^bio1a2,^ch4,^chè2vre3feuille,^ci2s1alp,^co1o2,^co2o3lie,^com3ment$,^con4,^cons4,^contre1s2c,^contre3maître,^cul4,^dacryo1a2,^di1a2cid,^di1a2cé,^di1a2mi,^di1a2tom,^di1ald,^di1e2n,^di2s3h,^do3lent$,^dy2s1a2,^dy2s1i2,^dy2s1o2,^dy2s1u2,^dy2s3,^dé1a2,^dé1io,^dé1o2,^dé2s,^dé2s1i2,^dé2s1oe0,^dé2s1u2n,^dé2s1½0,^dé2s1é2,^dé3s2a3cr,^dé3s2a3tell,^dé3s2astr,^dé3s2c,^dé3s2ensib,^dé3s2ert,^dé3s2exu,^dé3s2i3d,^dé3s2i3gn,^dé3s2i3li,^dé3s2i3nen,^dé3s2i3r,^dé3s2invo,^dé3s2ist,^dé3s2o3dé,^dé3s2o3l,^dé3s2o3pil,^dé3s2orm,^dé3s2orp,^dé3s2oufr,^dé3s2p,^dé3s2t,^dé3s2é3gr,^dés2a3m,^e4,^en1a2,^en1o2,^eu2r1a2,^gem2ment$,^i4,^in1a2,^in1e2,^in1i2,^in1o2,^in1s2tab,^in1u2,^in1é2,^in2a3nit,^in2augur,^in2effab,^in2ept,^in2er,^in2exora,^in2i3miti,^in2i3q,^in2i3t,^in2o3cul,^in2ond,^in2u3l,^in2uit,^in2é3lucta,^in2é3narra,^inte4r3,^intera2,^intere2,^interi2,^intero2,^inters2,^interu2,^interé2,^kh4,^la3tent$,^ma2c3k,^ma2l1a2dres,^ma2l1a2dro,^ma2l1a2v,^ma2l1aisé,^ma2l1ap,^ma2l1en,^ma2l1int,^ma2l1o2d,^ma2l1oc,^ma2r1x,^macro1s2c,^milli1am,^mono1a2,^mono1e2,^mono1i2,^mono1o2,^mono1s2,^mono1u2,^mono1é2,^mono1ï2dé,^mé2g1oh,^mé2s1es,^mé2s1i,^mé2s1u2s,^mé2sa,^mé3san,^méta1s2ta,^no2n1obs,^o4,^on3guent$,^oua1ou,^ovi1s2c,^pa2n1a2f,^pa2n1a2mé,^pa2n1a2ra,^pa2n1is,^pa2n1o2ph,^pa2n1opt,^pa2r1a2che,^pa2r1a2chè,^pa2r3hé,^pa3rent$,^pa3tent$,^para1s2,^pe4r,^pen2ta,^per1a2,^per1e2,^per1i2,^per1o2,^per1u2,^per1é2,^ph4,^phalan3s2t,^pluri1a,^pon2tet,^pos2t1in,^pos2t1o2,^pos2t3h,^pos2t3r,^post1s2,^pro1s2cé,^pro1é2,^prou3d2h,^pré1a2,^pré1e2,^pré1i2,^pré1o2,^pré1s2,^pré1u2,^pré1é2,^pré2a3la,^pré2au,^psycho1a2n,^pud1d2l,^péri1os,^péri1s2,^péri1u2,^péri2s3s,^péri2s3ta,^re1s2,^re2s3cap,^re2s3cisi,^re2s3ciso,^re2s3cou,^re2s3cri,^re2s3pect,^re2s3pir,^re2s3plend,^re2s3pons,^re2s3quil,^re2s3s,^re2s3t,^re3s4tab,^re3s4tag,^re3s4tand,^re3s4tat,^re3s4tim,^re3s4tip,^re3s4toc,^re3s4top,^re3s4tr,^re3s4tu,^re3s4ty,^re3s4tén,^re3s4tér,^re4s5trein,^re4s5trict,^re4s5trin,^res3sent$,^ré1a2,^ré1e2,^ré1i2,^ré1o2,^ré1é2,^ré2a3le,^ré2a3lis,^ré2a3lit,^ré2aux,^ré2el,^ré2er,^ré2i3fi,^ré2uss,^ré2èr,^rétro1a2,^réu2,^sar3ment$,^sch4,^ser3ment$,^seu2le,^sh4,^sou3vent$,^sta2g3n,^stil3l,^su2b1a2,^su2b1in,^su2b1ur,^su2b1é2,^su2b3limin,^su2b3lin,^su2b3lu,^su2r1a2,^su2r1e2,^su2r1i2m,^su2r1inf,^su2r1int,^su2r1of,^su2r1ox,^su2r1é2,^su2r3h,^su3b2alt,^su3b2é3r,^su3r2a3t,^su3r2eau,^su3r2ell,^su3r2et,^ta3lent$,^th4,^tri1a2c,^tri1a2n,^tri1a2t,^tri1o2n,^u4,^y4,^â4,^è4,^é4,^émi3nent$,^ê4,^î4,^ô4,^û4,1a2nesthési,1alcool,1b2l,1b2r,1ba,1be,1bi,1bo,1bu,1by,1bâ,1bè,1bé,1bê,1bî,1bô,1bû,1c2h,1c2k,1c2l,1c2r,1ca,1ce,1ci,1co,1coe0,1cu,1cy,1c½0,1câ,1cè,1cé,1cê,1cî,1cô,1cû,1d2r,1da,1de,1di,1do,1du,1dy,1dâ,1dè,1dé,1dê,1dî,1dô,1dû,1f2l,1f2r,1fa,1fe,1fi,1fo,1fu,1fy,1fâ,1fè,1fé,1fê,1fî,1fô,1fû,1g2ha,1g2he,1g2hi,1g2ho,1g2hy,1g2l,1g2n,1g2r,1ga,1ge,1gi,1go,1gu,1gy,1gâ,1gè,1gé,1gê,1gî,1gô,1gû,1ha,1he,1hi,1ho,1hu,1hy,1hâ,1hè,1hé,1hê,1hî,1hô,1hû,1informat,1j,1k2h,1k2r,1ka,1ke,1ki,1ko,1ku,1ky,1kâ,1kè,1ké,1kê,1kî,1kô,1kû,1la,1le,1li,1lo,1lu,1ly,1là,1lâ,1lè,1lé,1lê,1lî,1lô,1lû,1m2nès,1m2némo,1m2nési,1ma,1me,1mi,1mo,1moe0,1mu,1my,1m½0,1mâ,1mè,1mé,1mê,1mî,1mô,1mû,1na,1ne,1ni,1no,1noe0,1nu,1ny,1n½0,1nâ,1nè,1né,1nê,1nî,1nô,1nû,1octet,1p2h,1p2l,1p2neu,1p2né,1p2r,1p2sych,1p2tèr,1p2tér,1pa,1pe,1pi,1po,1pu,1py,1pâ,1pè,1pé,1pê,1pî,1pô,1pû,1q,1r2h,1ra,1re,1ri,1ro,1ru,1ry,1râ,1rè,1ré,1rê,1rî,1rô,1rû,1s2caph,1s2ch,1s2clér,1s2cop,1s2h,1s2lav,1s2lov,1s2patia,1s2perm,1s2phèr,1s2phér,1s2piel,1s2piros,1s2por,1s2tandard,1s2tein,1s2tigm,1s2tock,1s2tomos,1s2troph,1s2tructu,1s2tyle,1sa,1se,1si,1so,1soe0,1su,1sy,1s½0,1sâ,1sè,1sé,1sê,1sî,1sô,1sû,1t2h,1t2r,1ta,1te,1ti,1to,1tu,1ty,1tà,1tâ,1tè,1té,1tê,1tî,1tô,1tû,1v2r,1va,1ve,1vi,1vo,1vu,1vy,1vâ,1vè,1vé,1vê,1vî,1vô,1vû,1w2r,1wa,1we,1wi,1wo,1wu,1za,1ze,1zi,1zo,1zu,1zy,1zè,1zé,1ç,1é2drie,1é2drique,1é2lectr,1é2lément,1é2nerg,2bent$,2blent$,2brent$,2cent$,2chb,2chent$,2chg,2chm,2chn,2chp,2chs,2cht,2chw,2ck3h,2ckb,2ckent$,2ckf,2ckg,2ckp,2cks,2ckt,2clent$,2crent$,2dent$,2dlent$,2drent$,2fent$,2flent$,2frent$,2gent$,2glent$,2gnent$,2grent$,2guent$,2jent$,2jk,2kent$,2lent$,2nent$,2pent$,2phent$,2phn,2phs,2pht,2plent$,2prent$,2quent$,2r3heur,2r3hydr,2rent$,2s3hom,2schs,2sent$,2shent$,2shm,2shr,2shs,2t3heur,2tent$,2thl,2thm,2thn,2ths,2trent$,2vent$,2vrent$,2went$,2xent$,2zent$,3d2hal,3d2houd,3ph2talé,3ph2tis,4be$,4bes$,4ble$,4bles$,4bre$,4bres$,4ce$,4ces$,4ch$,4che$,4ches$,4chle$,4chles$,4chre$,4chres$,4ck$,4cke$,4ckes$,4cle$,4cles$,4cre$,4cres$,4de$,4des$,4dre$,4dres$,4fe$,4fes$,4fle$,4fles$,4fre$,4fres$,4ge$,4ges$,4gle$,4gles$,4gne$,4gnes$,4gre$,4gres$,4gue$,4gues$,4he$,4hes$,4je$,4jes$,4ke$,4kes$,4kh$,4le$,4les$,4me$,4mes$,4ne$,4nes$,4pe$,4pes$,4ph$,4phe$,4phes$,4phle$,4phles$,4phre$,4phres$,4ple$,4ples$,4pre$,4pres$,4que$,4ques$,4re$,4res$,4rhe$,4rhes$,4sch$,4sche$,4sches$,4se$,4ses$,4sh$,4she$,4shes$,4te$,4tes$,4th$,4the$,4thes$,4thre$,4thres$,4tre$,4tres$,4ve$,4ves$,4vre$,4vres$,4we$,4wes$,4ze$,4zes$,a1è2dre,a2l1algi,a2s3tro,ab2h,ab3sent$,absti3nent$,abî2ment$,ac3cent$,acquies4cent$,ad2h,ai2ment$,amalga2ment$,ani2ment$,antifer3ment$,apo2s3tr,appa3rent$,ar2ment$,archi1é2pis,armil5l,as2ment$,au2ment$,avil4l,bou2ment$,boutil3l,bru2ment$,ca3ou3t2,capil3l,carê2ment$,cci3dent$,ch2l,ch2r,chevil4l,chien3dent$,chlo2r3a2c,chlo2r3é2t,chro2ment$,cil3l,cla2ment$,co1a2d,co1acc,co1acq,co1ap,co1ar,co1assoc,co1assur,co1au,co1ax,co1ef,co1en,co1ex,co1é2,co2nurb,compé3tent$,confi3dent$,conni3vent$,conti3nent$,contin3gent$,corpu3lent$,cur3rent$,cyril3l,d1d2h,d1s2,da2ment$,di2s3cop,dia2g3n,diaphrag2ment$,dili3gent$,dissi3dent$,distil3l,déca3dent$,détri3ment$,e2n1i2vr,e2s3ch,e2s3cop,entre3gent$,er2ment$,es3cent$,esti2ment$,eu1s2tat,extra1,extra2c,extra2i,f1s2,fa2ment$,fichu3ment$,fir2ment$,flam2ment$,fritil3l,fu2ment$,fécu3lent$,g1s2,gil3l,gram2ment$,grandilo3quent$,hil3l,hu2ment$,hype4r1,hypera2,hypere2,hyperi2,hypero2,hypers2,hyperu2,hyperé2,hypo1a2,hypo1e2,hypo1i2,hypo1o2,hypo1s2,hypo1u2,hypo1é2,hémi1é,hémo1p2t,i1algi,i1arthr,i1oxy,i1s2tat,i1è2dre,i2s3chia,i2s3chio,i2s3ché,ibril3l,il2l,imma3nent$,immi3nent$,immis4cent$,impo3tent$,impu3dent$,inci3dent$,indi3gent$,indo3lent$,indul3gent$,inno3cent$,inso3lent$,instil3l,intelli3gent$,inti2ment$,io1a2ct,is3cent$,iva3lent$,ja3cent$,l1s2t,l2ment$,l3lion,la2w3re,lil3l,llu2ment$,m1s2,mi2ment$,mil3l,mil4let,mit3tent$,mon2t3réal,monova3lent$,moye2n1â2g,munifi3cent$,mécon3tent$,n1x,n3s2at$,n3s2ats$,nutri3ment$,o1d2l,o1ioni,o1s2tas,o1s2tat,o1s2tim,o1s2tom,o1s2trad,o1s2tratu,o1s2triction,o1s2téro,o1è2dre,o2b3long,om2ment$,ombud2s3,omni1s2,omnipo3tent$,opu3lent$,or2ment$,oxy1a2,paléo1é2,papil3la,papil3le,papil3li,papil3lom,per3h,perma3nent$,perti3nent$,ph2l,ph2r,photo1s2,piril3l,plu2ment$,po1astre,poly1a2,poly1e2,poly1i2,poly1o2,poly1s2,poly1u2,poly1è2,poly1é2,polyva3lent$,privatdo3cent$,privatdo3zent$,pro2s3tat,proémi3nent$,pru3dent$,pré3sent$,préémi3nent$,pupil3l,pusil3l,pé1r2é2q,pé2nul,qua2ment$,ra2ment$,radio1a2,rai3ment$,rcil4l,re3lent$,re3pent$,reli2ment$,ri2ment$,rin3gent$,rmil4l,ru3lent$,ryth2ment$,ré3gent$,réma3nent$,résur3gent$,réti3cent$,semil4l,ser3gent$,ser3pent$,sesqui1a2,slalo2ment$,sporu4lent$,stéréo1s2,su2ment$,su3r2ah,sub1s2,subli2ment$,succu3lent$,supe4r1,supero2,supers2,surémi3nent$,t1t2l,ta2ment$,tachy1a2,tan3gent$,tchin3t2,tempéra3ment$,ter3gent$,testa3ment$,th2r,thermo1s2,thril3l,to2ment$,tor3rent$,tran2s1a2,tran2s1o2,tran2s1u2,tran2s3h,tran2s3p,tran3s2act,tran3s2ats,transpa3rent$,tri3dent$,trucu3lent$,tu2ment$,tung2s3,turbu3lent$,télé1e2,télé1i2,télé1o2b,télé1o2p,télé1s2,u2s3tr,ucil4l,uevil4l,uni1a2x,uni1o2v,uvil4l,vacil4l,vanil3lin,vanil3lis,veni2ment$,ventripo3tent$,vidi2ment$,vil3l,vol2t1amp,vélo1s2ki,wa2g3n,xil3l,y1algi,y1asth,y1s2tom,â2ment$,è2ment$,é3cent$,é3dent$,é3quent$,é3rent$,éci2ment$,écu2ment$,éd2hi,éli2ment$,élo3quent$,émil4l,éni3tent$,épi2s3cop,épi3s4cope,équipo3tent$,équiva4lent$,ô2ment$,d4s$',',')"/>

<!-- uncomment the 2 functions if standalone use; part of nat-functs library -->
<!-- insert the char $char after each chars of $arg except for digits and supresses '$' and '^' -->

<xsl:function name="nat:insert-char-if-not-digit" as="xs:string" xmlns:nat="http://natbraille.free.fr/xsl" >
        <xsl:param name="arg" as="xs:string?"/>
        <xsl:param name="char" as="xs:string?"/>

        <xsl:variable name="tab" select="string-to-codepoints($arg)" as="xs:integer*"/>
        <xsl:variable name="retour" as="xs:string*">
                <xsl:for-each select="$tab">
                        <xsl:variable name="i" select="position()" as="xs:integer"/>
                        <xsl:value-of select="
                                if (not(string-to-codepoints('^')=. or string-to-codepoints('$')=.))
                                then
                                if (. &lt; string-to-codepoints('9') and . &gt; string-to-codepoints('0')  or
                                        ($tab[$i + 1] &lt; string-to-codepoints('9') and $tab[$i + 1] &gt; string-to-codepoints('0')))
                                then codepoints-to-string(.)
                                else concat(codepoints-to-string(.),$char)
                                else ''
                        "/>
                </xsl:for-each>
        </xsl:variable>
        <xsl:value-of select="string-join($retour,'')"/>
</xsl:function>
<!-- uncomment if standalone use -->
<!-- inserts the char $char after each char of $arg if not a '^' or a '$'-->           
                          
<xsl:function name="nat:insert-char" as="xs:string" xmlns:nat="http://natbraille.free.fr/xsl" >                   
        <xsl:param name="arg" as="xs:string?"/>                                                                   
        <xsl:param name="char" as="xs:string?"/>
        <xsl:value-of select="string-join(
                for $ch in string-to-codepoints($arg)
                return if (not(codepoints-to-string($ch)='^' or codepoints-to-string($ch)='$'))
                then concat(codepoints-to-string($ch),$char)
                else codepoints-to-string($ch),'')
        "/>
</xsl:function>


<!-- patterns with '1,2,3,4' replaced by '0'-->
<xsl:variable name="patterns0" select="for $pat in $patterns return nat:insert-char(translate($pat,'1234',''),'0')" as="xs:string*"/>
<!-- 0 inserted if not present between 2 chars (he2l1lo becomes h0e2l1l0o)-->
<xsl:variable name="patterns0nd" as="xs:string*">
	<xsl:for-each select="$patterns">
		<xsl:value-of select="nat:insert-char-if-not-digit(.,'0')" />
	</xsl:for-each>
</xsl:variable>

<!-- for testing; source document must contain "word" tags
The "-" char plays the hyphen role
 -->
<xsl:template match="word">
	<xsl:value-of select="nat:hyphenate(.,'-')"/>
</xsl:template>

<!--fr: *********** function de coupure litteraire basée sur liste de pattern de coupure ****************** -->
<!--en: *********** hyphenation function for literary texts based on patterns ****************** -->
<xsl:function name="nat:hyphenate" as="xs:string" xmlns:nat="http://natbraille.free.fr/xsl">
	<xsl:param name="mot" as="xs:string" /><!-- le mot à couper/ the word to be cut -->
	<xsl:param name="cp" as="xs:string" /><!-- le caractère de coupe/ the hyphen char -->

	<xsl:if test="$debug"><xsl:message select="concat('{mot: ',$mot,'} -------')"/></xsl:if>
	<xsl:choose>
		<!-- fr: le mot contient des caractères qui vont faire planter la fonction -->
		<!-- the word mays contains '1', '2', '3' or '3': we don't allow hyphenation so the word isn't cut -->
		<xsl:when test="contains(translate($mot,'234','111'),'1')">
			<xsl:value-of select="$mot"/>
		</xsl:when>
		<!-- fr: pas de caractère interdit -->
		<!-- en: the word is hyphenate-compliant -->
		<xsl:otherwise>
			<!-- fr: préparation du mot -->
			<!-- en: the word is re-written with '0' after each char -->
			<xsl:variable name="motCoup" select="nat:insert-char($mot,'0')" as="xs:string"/>
			<!--<xsl:message select="$motCoup"/>-->

			<!-- each matching pattern will give a re-written word with the pattern inserted
			for example, "hello" may match "l1l" and "e2l". "coupures" will be ('h0e0l1l0o','h0e2l0l0o') -->
			<xsl:variable name="coupures" as="xs:string*">
				<xsl:for-each select="$patterns">
					<xsl:variable name="i" select="position()" as="xs:integer"/>
					<!--<xsl:message select="concat('position:',position(),' pattern:',$patterns[$i])"/>-->
					<!-- <xsl:variable name="pattern" select="nat:insert-char(translate($patterns[$i],'1234',''),'0')" as="xs:string"/> -->
					<!--<xsl:message select="$pattern"/>-->

					<!-- each pattern is tested with the word -->
					<xsl:variable name="resu" as="xs:string">
						<xsl:value-of select="fn:replace($motCoup,$patterns0[$i],$patterns0nd[$i])"/>
					</xsl:variable>
					<xsl:if test="not($resu = $motCoup)"><!-- the pattern has matched -->
						<xsl:value-of select="$resu"/>
						<!-- only in debug mode -->
						<xsl:if test="$debug"><xsl:message select="concat(' * ',position(),
								': {pattern: ',$patterns[$i],
								'} {resultat:', $resu,'}')"/>
						</xsl:if>
					</xsl:if>
				</xsl:for-each>
			</xsl:variable>

			<!--<xsl:message select="string-join($coupures,';')"/>-->
			<!-- insertion des coupures -->
			<!-- we clean the result to obtain nice formed word: char + digit + char +digit, etc. -->
			<xsl:variable name="coupNet" as="xs:string*" select="
				for $coup in $coupures 
				return fn:replace(
					fn:replace(
						fn:replace(
							fn:replace(
								fn:replace($coup,'^0|^1|^2|^3|^4',''),'01','1'),'02','2'),'03','3'),'04','4')"/>
			<!--<xsl:message select="$coupNet"/>-->
			
			<!-- we sum each column to determine the final score of each hyphen position
			'h0e0l1l0o' + 'h0e2l0l0o' = h0e2l1l0o-->
			<xsl:variable name="coupureFin">
				<xsl:for-each select="string-to-codepoints($coupNet[1])">
					<xsl:variable name="i" select="position()" as="xs:integer"/>
					<xsl:choose>
						<xsl:when test="position() mod 2 = 1"><xsl:value-of select="codepoints-to-string(.)"/></xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="max(for $c in $coupNet return codepoints-to-string(string-to-codepoints($c)[$i]))"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:for-each>
			</xsl:variable>
			<!-- odd scores are replaced by the hyphen char -->
			<xsl:variable name="coupureOK" select="translate(fn:replace($coupureFin,'1$|3$',''),'13024',concat($cp,$cp))"/>
			<!-- pour le débuggage des règles -->
			<!-- for debuging -->
			<xsl:if test="$debug"><xsl:message select="concat('après LIANG: ',$coupureFin,' : ',$coupureOK)"/></xsl:if>
			<xsl:value-of select="if ($coupureOK = '') then $mot else $coupureOK"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:function>

</xsl:stylesheet>