[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Building html table from atributes

Subject: RE: Building html table from atributes
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 9 Aug 2002 10:03:53 +0100
td 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.