Transformation XML en XML
Bonjour,
Je galère pour modifier un fichier XSLT. J'ai un contenu de XML qui ressemble à ceci :
Code:
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 34
| <table:table table:name="dvp_code_other_3" table:style-name="dvp_5f_code_5f_other_5f_3">
<table:table-column table:number-columns-repeated="5" table:style-name="dvp_5f_code_5f_other_5f_3.A"/>
<table:table-column table:style-name="dvp_5f_code_5f_other_5f_3.F"/>
<table:table-row table:style-name="dvp_5f_code_5f_other_5f_3.1">
<table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.A1">
<text:p text:style-name="Table_20_Heading">other</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.A1">
<text:p text:style-name="Table_20_Heading">UYFUR origuh rugh ri rjg krgkr kr krjghkr kg kg hj</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.A1">
<text:p text:style-name="Table_20_Heading">Aucun</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.A1">
<text:p text:style-name="Table_20_Heading">0</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.A1">
<text:p text:style-name="Table_20_Heading">1</text:p>
</table:table-cell>
<table:table-cell office:value-type="string" table:style-name="dvp_5f_code_5f_other_5f_3.F1">
<text:p text:style-name="Table_20_Heading">fichier</text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="dvp_5f_code_5f_other_5f_3.2">
<table:table-cell office:value-type="string" table:number-columns-spanned="6" table:style-name="dvp_5f_code_5f_other_5f_3.A2">
<text:p text:style-name="Table_20_Contents">code</text:p>
</table:table-cell>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
</table:table-row>
</table:table> |
Je souhaiterais obtenir le xml suivant :
Code:
<code titre="other" cell2="UYFUR origuh rugh ri rjg krgkr kr krjghkr kg kg hj" cell3="Aucun" cell4="0" cell5="1" cell6="fichier">
Voici la portion d'xslt pour le moment
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| <xsl:template match="table:table[starts-with(@table:name, 'dvp_code_')]">
<code langage="{substring-before(substring-after(@table:name, 'dvp_code_'), '_')}">
<xsl:choose>
<xsl:when test="table:table-row[2]">
<xsl:attribute name="titre"><xsl:value-of select="table:table-row[1]/table:table-cell/text:p"/></xsl:attribute>
<xsl:apply-templates select="table:table-row[2]/table:table-cell/text:p" mode="code"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="table:table-row/table:table-cell/text:p" mode="code"/>
</xsl:otherwise>
</xsl:choose>
</code>
</xsl:template> |
J'ai essayé avant la fin du when ceci
Code:
1 2 3
| <xsl:if test="table:table-row[2]/table:table-cell[2]">
<xsl:attribute name="cell2"><xsl:value-of select="table:table-row[2]/table:table-cell[2]/text:p"/></xsl:attribute>
</xsl:if> |
Mais ça plante. Je ne sais pas quoi faire.
Est-ce le table:table-cell[2] qui pose souci ?
Merci