|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] using a param to determine how many columns to output.
Hi there,
I have written a template which matches elements and creates a table for each element which contains all the info from the XML document element I am interested in and this works fine. The problem is that I want to be able to create another table and populate this second table's rows and columns with the tables returned by the first template I refer to above. I have managed to stick the first set of tables in to the second but my problem comes in using a parameter to determine how many columns should appear in the table. Usually when programming I would expect to use a for loop using the parameter as a test for a counter which would create a new row for each say 2 elements. But I can't do this in XSLT... I had a go using the element position in the array element to try do this but am still getting nowhere... anyone able to suggest a suitable approach to solving this? It's very annoying to be so close to the requirement!!!! This is the template I have made (I hope this looks ok in a browser!) <xsl:template name="findAndExtractPageModelItemsIntoTable"> <xsl:for-each select="void"> <xsl:if test="string(@property)='pageItemModels'"> <table border="10"> <tr> <!-- with this commented in at this stage you get items within single row--> <!-- number of items in the array = <xsl:value-of select="array/@length" /><br /> number of cols to display = <xsl:value-of select="$cols" /><br /> --> <xsl:for-each select="array/void"> <!-- <tr> when this is commented in then I get new row per item, down the page--> <xsl:variable name="arrayIndex" select="@index + 1"/> arrayIndex = <xsl:value-of select="$arrayIndex" /> <br /> <xsl:if test="$arrayIndex <=$cols" > <td><xsl:call-template name="extractReportPageModelItem"/></td> </xsl:if> <xsl:if test="$arrayIndex >=$cols" > <td><xsl:call-template name="extractReportPageModelItem"/></td></tr> </xsl:if> <!-- </tr> --> </xsl:for-each> <!-- </tr> --> </table> </xsl:if> </xsl:for-each> </xsl:template> the logic being:
for each array/void //the element or node where I know the PageItem data is { if this node position <= cols { <td>call the template which returns a table itself </td> } if this node position >= cols { <td>call the template which returns a table itself </td><close row tag> } } close the table tags } }
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








