RE: Building html table from atributes
> > To make it sure that I understood correctly: > > > First an XSLT 2.0 solution: > > > > <xsl:variable name="doc" select="/XDocument"/> > // variable that points to root element > > > <xsl:for-each select="1 to max($doc/XDocCell/@col)"> > // selects all elements (attribute col of XDocCells) from 1 > to the max, > // using the doc variable. No, it selects a sequence of numbers 1,2,3 up to the highest value of @col in your document. > > > <xsl:variable name="col" select="position()"/> > // col variable that declares position We could have equally written select=".": this is the current column number > > > <tr> > > <xsl:for-each select="1 to max($doc/XDocCell/@row)"> > // selects all elements (attribute row of XDocCells) from 1 > to the max, // using the doc variable. We're now selecting a sequence of numbers from 1,2,3 up to the highest @row number in your document [I can't think why I did it this way round, you want rows in the outer loop and columns in the inner loop, of course] > > > <xsl:variable name="row" select="position()"/> > // row variable that declares position > > > <td><xsl:value-of select="$doc/XDocCell[@row=$row and > > @col=$col]"/></td> > // selects all row and col atributes (from xml file) that > equals // variables row and col We now select the cell with the particular row and column number, if there is one, and output it. If there isn't one, we output nothing. If there are two, <xsl:value-of> selects the first. The logic is for row from 1 to n <tr> for column from 1 to m <td> output cell[row, column] </td> end-for </tr> end-for Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
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