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
| <xsl:template name="capitalize">
<xsl:param name="string"/>
<xsl:param name="caps" select="false()"/>
<xsl:variable name="separator" select="abcdefghijklmnopqrstuvwxyzàâäãéèêëìïîòôöõùûüñABCDEFGHIJKLMNOPQRSTUVWXYZ"/>
<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="nextToCaps">
<xsl:if test="contains($separator, substring($string, 1,1))">
<xsl:value-of select="false()" />
</xsl:if>
<xsl:if test="not( contains($separator, substring($string, 1,1)) )">
<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> |
Partager