J'ai un xml comme ceci.XSLT pour XML vers HTML table
< cars>
< car>
< ford color="black" >eco sport</ford>
< maruti color="red" >zen< /maruti>
< hyundai color="blue" >accent< /hyundai>
< /car>
< car>
< ford color="green" >figo</ford>
< maruti color="red" >swift< /maruti>
< hyundai color="white" >santro< /hyundai>
< /car>
< /cars>
je dois avoir une table HTML comme
COMPANY COLOR MODEL
ford black ecosport
maruti red zen
hyundai green figo
ford red swift
maruti red zen
hyundai white santro
Quelqu'un pourrait-il me aider .. Je suis très nouveau pour XSLT et a passé quelque temps valuble pour cela, mais pas de chance. Merci d'avance. Ci-dessous le XSLT j'ai essayé avec
<xsl:template match ="/">
<html>
<head>
<title> Cars </title>
</head>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="cars">
<table width="400" border="1" >
<tr bgcolor = "#cccccc" >
<td>COMPANY</td>
<td>COLOR</td>
<td>MODEL</td>
</tr>
<xsl:for-each select="car">
<tr>
<xsl:for-each select="./">
<td><xsl:value-of select="name()"/></td>
<td> <xsl:value-of select="@color" /> </td>
<td> <xsl:value-of select="ford" /> </td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
Merci beaucoup. Cela fonctionne absolument. Une question de plus même si. Puis-je avoir un retrait avant «zen» si l'élément est égal à maruti? –
Vous voulez donc espacer à gauche du nom du modèle uniquement pour Maruti zens? – JLRishe
oui .. donc mon état devrait être comme si 'maruti' puis 2 espaces zen nad dans la rangée suivante si 'hyundai' puis 3 espaces accent –