I have a SQL query that produces results with 7 columns and several rows of data.
I convert this into XML and run it through XSLT to produce HTML and everything works fine. XSLT output looks like this:
Header info
Row 1: 1 | 2 | 3 | 4 | 5 | 6 | 7 |
Row 2: 1 | 2 | 3 | 4 | 5 | 6 | 7 |
But now the data in some of the columns takes up a lot of room and I now need to stack the columns in XSLT to produce results like this:
1 | 2 | 3 |
4 | 5 | 6 |
7
I'd like column 4 to go under column 1 and 7 to span across the 3 columns above it.
here is a much simplified version of my XML:
<XML_Data>
<Row>
<EMP_ID>APf92C56</EMP_ID>
<ID>129190950</ID>
<KEY>H59460973</KEY>
<COMP_TS>2015-01-26 11:31</COMP_TS>
<CODE>500</CODE>
<REASON>Text String</REASON>
<CREATE_Reason>Very long text string</CREATE_Reason>
</Row>
<Row>
<EMP_ID>APf92C56</EMP_ID>
<ID>129190950</ID>
<KEY>H59460973</KEY>
<COMP_TS>2015-01-26 11:31</COMP_TS>
<CODE>500</CODE>
<REASON>Text String</REASON>
<CREATE_Reason>Very long text string</CREATE_Reason>
</Row>
</XML_Data>
Here is my current XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/ROOT">
<table border="0" cellpadding="6">
<tr>
<td style="font-weight:bold;">EMP_ID</td>
<td style="font-weight:bold;">ID</td>
<td style="font-weight:bold;">KEY</td>
<td style="font-weight:bold;">COMP_TS</td>
<td style="font-weight:bold;">CODE</td>
<td style="font-weight:bold;">REASON</td>
<td style="font-weight:bold;">CREATE_Reason</td>
</tr>
<xsl:for-each select="XML_Data/Row">
<tr>
<xsl:for-each select="./*">
<td>
<xsl:value-of select="." disable-output-escaping="yes" />
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
I read this response: XSL xsl:template match="/" and played around with <xsl:template match="element">
but without knowing how to force a column onto a new line I didn't get very far.
I know SO is not a code generation tool, but I've combed through books and online and cant find what I'm looking for. Any help, even if its just a push in the right direction, would be most appreciated.