I have been trying to work on a variation of a question I asked last week.
XSL for Xml to table transformation.
I have to output the the first and last page number of each section into a table with two rows.
I'm confused on how integrate a two row table with the Muenchian grouping Method
The XSLT 1.0 Solution is what I need. I have solution below for one, but I need two rows.
Any advice or guidance will be much appreciate.
Input:
<root>
<page number="1" section="Arsenal">Arsenal</page>
<page number="2" section="Arsenal">Arsenal</page>
<page number="3" section="Arsenal">Arsenal</page>
<page number="4" section="Arsenal">Arsenal</page>
<page number="5" section="Arsenal">Arsenal</page>
<page number="6" section="Arsenal">Arsenal</page>
<page number="7" section="Chelsea">Chelsea</page>
<page number="8" section="Chelsea">Chelsea</page>
<page number="9" section="Chelsea">Chelsea</page>
<page number="10" section="Chelsea">Chelsea</page>
<page number="11" section="Chelsea">Chelsea</page>
<page number="12" section="Chelsea">Chelsea</page>
<page number="13" section="ManUnited">ManUnited</page>
<page number="14" section="ManUnited">ManUnited</page>
<page number="15" section="ManUnited">ManUnited</page>
<page number="16" section="ManUnited">ManUnited</page>
<page number="17" section="ManUnited">ManUnited</page>
<page number="18" section="ManUnited">ManUnited</page>
<page number="19" section="ManCity">ManCity</page>
<page number="20" section="ManCity">ManCity</page>
<page number="21" section="ManCity">ManCity</page>
<page number="22" section="ManCity">ManCity</page>
<page number="23" section="ManCity">ManCity</page>
<page number="24" section="ManCity">ManCity</page>
</root>
Output:
<table>
<tr>
<td>Arsenal</td>
<td></td>
<td>Chelsea</td>
<td></td>
<td>ManU</td>
<td></td>
<td>ManCity</td>
<td></td>
</tr>
<tr>
<td>1</td>
<td>6</td>
<td>7</td>
<td>12</td>
<td>13</td>
<td>18</td>
<td>19</td>
<td>24</td>
</tr>
</table>
This is my current XSLT logic.
<table>
<tr>
<xsl:apply-templates select="page[generate-id() = generate-id(key('kSection', @section))]"/>
</tr>
</table>
</xsl:template>
<xsl:template match="page">
<td>
<xsl:value-of select="@section"/>
</td>
<td>
<xsl:value-of select="@number"/>
</td>
<td>
<xsl:value-of select="key('kSection', @section)[last()]/@number"/>
</td>
</xsl:template>
</xsl:stylesheet>
Regards JJ.