[XSLT]Wordml --> XMl les tables
Bonjour,
Je travaille sur un xslt ayant pour but de convertir du wordml (Xml généré par Word) vers un fichier Xml utilisé dans nos applications. Mon (premier ?!) problème vient de la façon dont les tables sont codée dans le Wordml. En effet, les tables sont décrites colonnes par colonnes alors que je dois encoder cela dans le fichier xml ligne par ligne (un peu comme l'Html). Ce petit exemple sera sans doute plus clair :
Format Wordml (note : j'ai simplifié un peu le code pour le présenter ici, il se peu qu'il manque l'une ou l'autre balise)
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
<w:tbl>
<w:tblGrid>
<w:gridCol w:w="2268"/>
<w:gridCol w:w="2268"/>
<w:gridCol w:w="2268"/>
</w:tblGrid>
<w:tr wsp:rsidR="00534855" wsp:rsidRPr="0091496B" wsp:rsidTr="00445279">
<w:tc>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00162125">
<w:t>Age</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00162125">
<w:t>Poids corporel</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00162125">
<w:t>Nombre de gouttes</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
<w:tr wsp:rsidR="00534855" wsp:rsidRPr="0091496B" wsp:rsidTr="00445279">
<w:tc>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00E3038B">
<w:t>1 an</w:t>
</w:r>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00E3038B">
<w:t>3 ans</w:t>
</w:r>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00E3038B">
<w:t>6 ans</w:t>
</w:r>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00E3038B">
<w:t>9 ans</w:t>
</w:r>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00E3038B">
<w:t>11 ans</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<st1:metricconverter ProductID="10ᅠkg" w:st="on">
<w:r wsp:rsidRPr="00162125">
<w:t>10*kg</w:t>
</w:r>
</st1:metricconverter>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<st1:metricconverter ProductID="15ᅠkg" w:st="on">
<w:r wsp:rsidRPr="00162125">
<w:t>15*kg</w:t>
</w:r>
</st1:metricconverter>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<st1:metricconverter ProductID="20ᅠkg" w:st="on">
<w:r wsp:rsidRPr="00162125">
<w:t>20*kg</w:t>
</w:r>
</st1:metricconverter>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<st1:metricconverter ProductID="30ᅠkg" w:st="on">
<w:r wsp:rsidRPr="00162125">
<w:t>30*kg</w:t>
</w:r>
</st1:metricconverter>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<st1:metricconverter ProductID="45ᅠkg" w:st="on">
<w:r wsp:rsidRPr="00162125">
<w:t>45*kg</w:t>
</w:r>
</st1:metricconverter>
</w:p>
</w:tc>
<w:tc>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00162125">
<w:t>4 8</w:t>
</w:r>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00162125">
<w:t>6 12</w:t>
</w:r>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00162125">
<w:t>8 16</w:t>
</w:r>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00162125">
<w:t>12 24</w:t>
</w:r>
</w:p>
<w:p wsp:rsidR="00534855" wsp:rsidRPr="00E3038B" wsp:rsidRDefault="00534855" wsp:rsidP="00E3038B">
<w:r wsp:rsidRPr="00162125">
<w:t>18 36</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
</w:tbl> |
on voit vlairement que la table est définie colonne par colonne.
l'xsd de l'xml a produire définit quand a lui la table ligne par ligne, voici la partie de l'xsd qui définit une table :
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
|
<xs:element name="table">
<xs:complexType>
<xs:sequence>
<xs:element name="row" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="column" maxOccurs="unbounded">
<xs:complexType>
<xs:complexContent>
<xs:extension base="blockType">
<xs:attribute name="header" type="xs:boolean" use="optional" default="false"/>
<xs:attribute name="width" type="xs:integer" use="optional"/>
<xs:attribute name="colspan" type="xs:integer" use="optional" default="0"/>
<xs:attribute name="rowspan" type="xs:integer" use="optional" default="0"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="class-id" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="class-id" type="xs:string" use="optional"/>
<xs:attribute name="border" type="xs:integer" use="optional"/>
<xs:attribute name="width" type="xs:integer" use="optional"/>
<xs:attribute name="cellpadding" type="xs:integer" use="optional"/>
<xs:attribute name="cellspacing" type="xs:integer" use="optional"/>
</xs:complexType>
</xs:element> |
Existe-t-il un moyen via xslt de passer d'une description colonne par colonne a la description ligne par ligne ?
D'après ce que je sais de l'xslt, ça me parrait impossible puisqu'il prend les éléments les uns à la suite des autres et qu'aucun "branchement" n'est possible :(