[XSLT] Problème avec la fonction contains
Bonjour à tous,
Cela fait une matinée complète que je planche sur une méthode de capitalisation des mots d'une phrase. Mon problème est que c'est la totalité de ma phrase qui se retrouve mise en majuscule O_o. J'ai l'impression que le "contains" renvoie toujours faux. Et je comprend pas pourquoi...
Merci de votre aide.
Ci dessous mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <xsl:template name="capitalize">
<xsl:param name="string"/>
<xsl:param name="caps" select="false()"/>
<xsl:variable name="separator" select="a"/>
<xsl:if test="$caps">
<xsl:value-of select="translate(substring($string, 1,1), 'abcdefghijklmnopqrstuvwxyzàâäãéèêëìïîòôöõùûüñ','ABCDEFGHIJKLMNOPQRSTUVWXYZAAAAEEEEIIIOOOOUUUN')" />
</xsl:if>
<xsl:if test="not($caps)">
<xsl:value-of select="translate(substring($string, 1,1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') " />
</xsl:if>
<xsl:variable name="char" select="substring($string, 1,1)" />
<xsl:variable name="nextToCaps">
<xsl:if test="contains($separator, $char)">
<xsl:value-of select="false()" />
</xsl:if>
<xsl:if test="not( contains($separator, $char) )">
<xsl:value-of select="true()" />
</xsl:if>
</xsl:variable>
<xsl:if test="string-length(substring($string, 2)) > 0">
<xsl:call-template name="capitalize">
<xsl:with-param name="string" select="substring($string, 2)" />
<xsl:with-param name="caps" select="$nextToCaps" />
</xsl:call-template>
</xsl:if>
</xsl:template> |