Transformation xslt: demande d'aide

Fermé
xslnewbie Messages postés 1 Date d'inscription lundi 21 septembre 2009 Statut Membre Dernière intervention 21 septembre 2009 - 21 sept. 2009 à 15:09
 calclf - 5 oct. 2009 à 20:53
Bonjour,
je souhaite faire la transformation suivante en xslt:

Source:
<ap:Topic DOId="DptmmZv5qkeUEAjLtRkqVA==">
<ap:Text PlainText="Texte du topic">
<ap:Font Bold="yes"/>
</ap:Text>
</ap:Topic>

Résultat:
<node ID="DptmmZv5qkeUEAjLtRkqVA" TEXT="Texte du topic">
<font BOLD="true"/>
</node>

Je fais coïncider ap:Topic dans la source avec node dans le résultat.
J'ai un problème pour générer le noeud font dans la cible, car je n'arrive pas à parcourir le noeud ap:Text deux fois :
<xsl:template match="ap:Topic">
<node>
<xsl:attribute name="TEXT">
<xsl:value-of select="./ap:Text/@PlainText" />
</xsl:attribute>
<xsl:apply-templates select="./ap:Text" />
</node>
</xsl:template>
<xsl:template match="ap:Text">
<xsl:apply-templates select="./ap:Font" />
</xsl:template>
<xsl:template match="ap:Font">
<xsl:element name="font">
<xsl:attribute name="BOLD">
<xsl:value-of select="@Bold"/>
</xsl:attribute>
</xsl:element>
</xsl:template>


Merci d'avance

1 réponse

<xsl:template match="ap:Topic">
<node>
<xsl:attribute name="ID">
<xsl:value-of select="@DOId" />
</xsl:attribute>
<xsl:attribute name="TEXT">
<xsl:value-of select="./ap:Text/@PlainText" />
</xsl:attribute>
<xsl:if test="./ap:Text/@Bold='yes'">
<font bold="true"/>
</xsl:if>
</node>
</xsl:template>
<xsl:template match="ap:Text">
</xsl:template>
<xsl:template match="ap:Font">
</xsl:template>
0