I have a question regarding XSLT transformation for ouput tables with fixed structure and variable input content.
I have outlined 2 different example.
The desired output table is 6 columns and two row.
But the desired td classes and content are dependent on the input XML
I have a previous example to start from provided by @Kirill Polishchuk
Extracting a class from the section attribute using xsl
Please note I'm working with XSLT 1.0. Any advice or guidance will be much appreciate.
Example 1
Input XML with 6 sections
<root>
<page number="1" section="Arsenal_Stadium">Arsenal_Stadium</page>
<page number="2" section="Arsenal_Stadium">Arsenal_Stadium</page>
<page number="3" section="Arsenal_Stadium">Arsenal_Stadium</page>
<page number="4" section="Arsenal_Stadium">Arsenal_Stadium</page>
<page number="5" section="Arsenal_Crowds">Arsenal_Crowds</page>
<page number="6" section="Arsenal_Crowds">Arsenal_Crowds</page>
<page number="7" section="Arsenal_Crowds">Arsenal_Crowds</page>
<page number="8" section="Arsenal_Crowds">Arsenal_Crowds</page>
<page number="9" section="Arsenal_Support">Arsenal_Support</page>
<page number="10" section="Arsenal_Support">Arsenal_Support</page>
<page number="11" section="Arsenal_Support">Arsenal_Support</page>
<page number="12" section="Arsenal_Support">Arsenal_Support</page>
<page number="13" section="Arsenal_Revenue">Arsenal_Revenue</page>
<page number="14" section="Arsenal_Revenue">Arsenal_Revenue</page>
<page number="15" section="Arsenal_Revenue">Arsenal_Revenue</page>
<page number="16" section="Arsenal_Revenue">Arsenal_Revenue</page>
<page number="17" section="Arsenal_Cost">Arsenal_Cost</page>
<page number="18" section="Arsenal_Cost">Arsenal_Cost</page>
<page number="19" section="Arsenal_Cost">Arsenal_Cost</page>
<page number="20" section="Arsenal_Cost">Arsenal_Cost</page>
<page number="21" section="Arsenal_Outlook">Arsenal_Outlook</page>
<page number="22" section="Arsenal_Outlook">Arsenal_Outlook</page>
<page number="23" section="Arsenal_Outlook">Arsenal_Outlook</page>
<page number="24" section="Arsenal_Outlook">Arsenal_Outlook</page>
</root>
Desired Output 6 rows & 2 columns
<table>
<tr>
<td class="Stadium">Stadium</td>
<td class="Crowds">Crowds</td>
<td class="Support">Support</td>
<td class="Revenue">Revenue</td>
<td class="Cost">Cost</td>
<td class="Outlook">Outlook</td>
</tr>
<tr>
<td class="Stadium_R2">1-4</td>
<td class="Crowds_R2">5-6</td>
<td class="Support_R2">7-10</td>
<td class="Revenue_R2">11-14</td>
<td class="Cost_R2">15-18</td>
<td class="Outlook_R2">19-22</td>
</tr>
</table>
Example 2
Input XML 4 sections
<root>
<page number="1" section="Arsenal_Stadium">Arsenal_Stadium</page>
<page number="2" section="Arsenal_Stadium">Arsenal_Stadium</page>
<page number="3" section="Arsenal_Stadium">Arsenal_Stadium</page>
<page number="4" section="Arsenal_Stadium">Arsenal_Stadium</page>
<page number="5" section="Arsenal_Support">Arsenal_Support</page>
<page number="6" section="Arsenal_Support">Arsenal_Support</page>
<page number="7" section="Arsenal_Support">Arsenal_Support</page>
<page number="8" section="Arsenal_Support">Arsenal_Support</page>
<page number="9" section="Arsenal_Cost">Arsenal_Cost</page>
<page number="10" section="Arsenal_Cost">Arsenal_Cost</page>
<page number="11" section="Arsenal_Cost">Arsenal_Cost</page>
<page number="12" section="Arsenal_Cost">Arsenal_Cost</page>
<page number="13" section="Arsenal_Outlook">Arsenal_Outlook</page>
<page number="14" section="Arsenal_Outlook">Arsenal_Outlook</page>
<page number="15" section="Arsenal_Outlook">Arsenal_Outlook</page>
<page number="16" section="Arsenal_Outlook">Arsenal_Outlook</page>
</root>
Desired Output 6 rows & 2 columns
<table>
<tr>
<td class="Stadium">Stadium</td>
<td class="Support">Support</td>
<td class="Cost">Cost</td>
<td class="Outlook">Outlook</td>
<td class="None"></td>
<td class="None"></td>
</tr>
<tr>
<td class="Stadium_R2">1-4</td>
<td class="Support_R2">5-8</td>
<td class="Cost_R2">9-12</td>
<td class="Outlook_R2">13-16</td>
<td class="None"></td>
<td class="None"></td>
</tr>
</table>
Regards JJ.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…