Bonjour,
Ca fait une semaine que je touche au XSL et j'ai une colle avec ce que je veux faire.
J'espère que quelqu'un saura m'aider !!
Voilà les données dans mon fichier XML :
1 2 3 4 5 6 7 8 9 10 11
|
<section intitue="Intitule1>
<line text="Texte de ligne 1">
<keyword kwdword="texte" kwdlink="00001.html" />
<line />
<line text="Ligne de texte 2">
<keyword kwdword="ligne" kwdlink="00002.html" />
<keyword kwdword="texte" kwdlink="00001.html" />
<line />
<line text="Ligne de texte 3" />
</section> |
Et je dois afficher ceci en html :
1 2 3 4 5
|
Intitule1
Ligne de <a href=00001.html">texte</a> 1
<a href="00002.html">Ligne</a> de <a href=00001.html">texte</a> 2
Ligne de texte 3 |
Le problème ne se passe pas au niveau du lien, ni quand j'ai un keyword sur la ligne, ça marche nickel. Mais de quand j'ai deux liens voir plusieurs sur la même ligne de texte :
En fait pour la ligne 2 j'ai ceci:
<a href="00002.html">Ligne</a> de texte 2Ligne de <a href=00001.html">texte</a> 2
Voici mon bout de code xsl qui gère les élément "line" :
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 30 31 32 33
| <xsl:template match="line">
<ul>
<xsl:choose>
<xsl:when test="keyword/@kwdword!=''">
<xsl:apply-templates select="keyword"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="substring(@text, 1, 1) = '-'">
<li>
<xsl:value-of select="substring-after(@text,'-')"/>
</li>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</ul>
</xsl:template>
<xsl:template match="line/keyword">
<!-- Découpage de la ligne en cours et introduction du lien -->
<xsl:value-of select="substring-before(../@text, @kwdword)"/>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@kwdlink"/>
</xsl:attribute>
<xsl:value-of select="@kwdword"/>
</xsl:element> |
Quelqu'un peut m'aider ?
Partager