I have following piece of XML file:
<PASS>
<FIRMWARE Unit="1" Group="FIRM">
<test name="ACPI" ID="ACPI" />
</FIRMWARE>
<NETWORK Unit="2" Group="NTWK">
<test name="Controller Test" ID="Ctlr" />
</NETWORK>
<NETWORK Unit="1" Group="NTWK">
<test name="Controller Test" ID="Ctlr" />
</NETWORK>
<ATA Unit="1" Group="ATA-">
<test name="Serial Controllers" ID="SATA" />
</ATA>
<PARALLEL_PORT Unit="1" Group="LPT-">
<test name="Verify Controller" ID="Ctrl" />
<test name="Check Status Port" ID="Stat" />
<test name="Interrupt Test" ID="Int-" />
</PARALLEL_PORT>
<SERIAL_PORT Unit="4" Group="COM-">
<test name="Interrupt" ID="Intr" />
<test name="Line Control" ID="Line" />
<test name="Test Loopback" ID="LpBk" />
<test name="Test Internal FIFO" ID="FIFO" />
<test name="Test Internal Loopback" ID="ILBk" />
</SERIAL_PORT>
<SERIAL_PORT Unit="3" Group="COM-">
<test name="Interrupt" ID="Intr" />
<test name="Line Control" ID="Line" />
<test name="Test Loopback" ID="LpBk" />
<test name="Test Internal FIFO" ID="FIFO" />
<test name="Test Internal Loopback" ID="ILBk" />
</SERIAL_PORT>
</PASS>
With the existing XSL file I get all test results in one column. This is not very practical for printing and so on. How can I create a table with 2 or more columns?
<xsl:template match="PASS">
<div class="component">
<h4>PASSED</h4>
<xsl:call-template name="outputtable">
<xsl:with-param name="result" select="'PASSED'" />
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="outputtable">
<div class="attributes">
<xsl:variable name="resultlist" select="*" />
<xsl:variable name="index" select="count(child::*)" />
<xsl:for-each select="$resultlist">
<xsl:variable name="Unit" select="@Unit" />
<xsl:variable name="Group" select="@Group" />
<p class="attrtitle">
<xsl:value-of select="name()" />
Unit:
<xsl:value-of select="$Unit" />
</p>
<xsl:variable name="testtype" select="*" />
<xsl:for-each select="$testtype">
<p class="attribute">
<xsl:value-of select="@name" />
</p>
</xsl:for-each>
<p />
</xsl:for-each>
</div>
I've already searched for solution and found following links: Use xslt to convert xml list into html table with multiple columns and http://blogs.msdn.com/b/kaevans/archive/2003/04/03/4754.aspx
The situation I have is rather different I have structured objects and not simple as "Item" or "ComputerName" and the other drawback is that those test are not of the same type (, etc.). This XML report is constructed automatically by non-OSS software, so I have no way to change it at creation time.
I'll be glad to get any ideas!
<xsl:for-each>-- templates are much more powerful and elegant.