: Hi,
: I've not been working with XML/XSL for long and I've hit a snag. I'm trying to fill out a table with info from my XML. Usually, I'd use 'xsl:for-each', but on this occasion I can't. Here is the XML:
:
:
: <root>
: <test>
: <data>
: <client>
: <name>Brian</name>
: <age>28</age>
: <colour>Red</colour>
: <smell>Pizza</smell>
: </client>
: <client>
: <name>Steven</name>
: <age>42</age>
: <colour>Cerise</colour>
: <smell>Baby poo</smell>
: </client>
: <client>
: <name>Raymond</name>
: <age>2</age>
: <colour>Blue</colour>
: <smell>Fish guts</smell>
: </client>
: <client>
: <name>Tam</name>
: <age>35</age>
: <colour>Green</colour>
: <smell>Beef crisps</smell>
: </client>
: </data>
: </test>
: </root>
:
:
: And here is the XSL transform I have so far:
:
:
: <?xml version="1.0"?>
: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
: <xsl:template match="/">
: <form action="" method="post">
: <table width="740" border="1" cellspacing="0" cellpadding="2" align="center">
: <xsl:variable name="counter" select="1"/>
: <xsl:variable name="nodecount"><xsl:value-of select="count(//root//test//data//client)"/></xsl:variable>
: <tr>
: <td>Name</td>
: <td>Age</td>
: <td>Colour</td>
: <td>Smell</td>
: <td>Select</td>
: </tr>
: <xsl:call-template name="table">
: <xsl:with-param name="counter"/>
: <xsl:with-param name="nodecount"/>
: </xsl:call-template>
: </table>
: </form>
: </xsl:template>
: <xsl:template name="table">
: <xsl:param name="counter"/>
: <xsl:param name="nodecount"/>
: <xsl:if test="$counter <=$nodecount">
: <tr>
: <td width="148"><xsl:value-of select="root/test/data/client/name"/></td>
: <td width="148"><xsl:value-of select="root/test/data/client/age"/></td>
: <td width="148"><xsl:value-of select="root/test/data/client/colour"/></td>
: <td width="148"><xsl:value-of select="root/test/data/client/smell"/></td>
: <td width="148"><input name="selectperson" type="checkbox" value=""/>Tick here to select</td>
: </tr>
: <xsl:call-template name="table">
: <xsl:with-param name="counter"><xsl:value-of select="$counter+1"/></xsl:with-param>
: <xsl:with-param name="nodecount" select="$nodecount"/>
: </xsl:call-template>
: </xsl:if>
: </xsl:template>
:
: </xsl:stylesheet>
:
: Any help would be greatly appreciated. Thanks in advance
What is the problem and why can't you use an xsl:for-each?
infidel
$ select * from users where clue > 0
no rows returned