Transformation xslt: demande d'aide
xslnewbie
Messages postés
1
Statut
Membre
-
calclf -
calclf -
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
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
A voir également:
- Transformation xslt: demande d'aide
- Transformation de voix - Guide
- Transformation en pdf - Guide
- Windows 7 transformation pack - Télécharger - Personnalisation
- Transformation jpg en pdf - Télécharger - PDF
- Photoshop transformation manuelle impossible - Forum Photoshop
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>
<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>