Bonjour !
Alors voilà mon soucis : j'ai une chaine de caractères 'bonjour, toto a un gros problème" qui contient une chaine 'toto', chaine que je voudrais remplacer par <br/> et qui serait interprétée comme un retour chariot.
Ma fonction :
Code :
- <xsl:template name="replace-string">
- <xsl:param name="text"/>
- <xsl:param name="from"/>
- <xsl:param name="to"/>
- <xsl:choose>
- <xsl:when test="contains($text, $from)">
- <xsl:variable name="before" select="substring-before($text, $from)"/>
- <xsl:variable name="after" select="substring-after($text, $from)"/>
- <xsl:variable name="prefix" select="concat($before, $to)"/>
- <xsl:value-of select="$before"/>
- <xsl:value-of select="$to"/>
- <xsl:call-template name="replace-string">
- <xsl:with-param name="text" select="$after"/>
- <xsl:with-param name="from" select="$from"/>
- <xsl:with-param name="to" select="$to"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$text"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
|
L'appel de la fonction :
Code :
- <xsl:call-template name="replace-string">
- <xsl:with-param name="text" select="MACHAINE"/>
- <xsl:with-param name="from" select="'toto'"/>
- <xsl:with-param name="to" select="<BR>"/>
- </xsl:call-template>
|
Et enfin le résultat affiché :
Code :
- bonjour, <BR/> a un gros problème
|
Donc le <BR/> n'est pas interprété !
Pourriez-vous me donner un coup de main ?
Merci !
EDIT : j'ai tenté de remplacer <BR> par mais sans succès
Message édité par moldar le 12-03-2007 à 11:42:04