Apply-template en cascades ...
Morio David <[email protected]>
| Newsgroups | gmane.text.xml.french.tech |
|---|---|
| Message-ID | <[email protected]> |
Bonjour,
je dispose d'un fichier XML que je transforme afin qu'il soit bien formaté pour Excel. Je ne maîtrise pas trop XSLT (ni Excel d'ailleurs !), et je suis face à un problème au niveau des définitions des <templates>et des <apply-template>. Voici le code dans les grandes lignes:
<xsl:stylesheet version="1.0"
<xsl:template match="/Data">
<Workbook>
<Worksheet ss:Name="Rapport">
<Table ss:DefaultColumnWidth="60" >
<!-- Les entêtes -->
<Row>
<Cell>...</Cell>
</Row>
<!-- Ligne COLLECTION -->
<xsl:apply-templates select="/Data/BODY/Class/Attribute" />
<!-- Lignes ARTICLES -->
<xsl:apply-templates select="//Attribute[attribute::dbname='PartNumber']" />
</Table>
</Worksheet>
</Workbook>
</xsl:template>
<xsl:template match="/Data/BODY/Class/Attribute">
<Row>
<Cell>...</Cell>
</Row>
</xsl:template>
<xsl:template match="//Attribute[attribute::dbname='PartNumber']">
<Row>
<Cell></Cell>
</Row>
<xsl:apply-templates select="../Relation[attribute::dbname='j3PartDc']/Class/Relation" />
</xsl:template>
<xsl:template match="../Relation[attribute::dbname='j3PartDc']/Class/Relation">
<Row>
<Cell></Cell>
</Row>
</xsl:template>
</xsl:stylesheet>
Donc, dans mon template principal /Data , j'appelle un second template "//Attribute[attribute::dbname='PartNumber']" , qui lui-même appelle un troisième template ="../Relation[attribute::dbname='j3PartDc']/Class/Relation.
les lignes de mon troisième template sont bien générées, mais non formatées en <Row><Cell>...données...</Cell></Row>.
Donc, j'ai essayé plusieurs contournements, mais je suis tjs bloqué.
Si vous pensez savoir pourquoi cela marche pas ...
D'avance merci.
---------------------------------
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.Téléchargez la version beta.