Re: [xsl] translate to XML using XSL into an HTML table

Subject: Re: [xsl] translate to XML using XSL into an HTML table
From: oryann9 <oryann9@xxxxxxxxx>
Date: Mon, 6 Aug 2007 08:32:30 -0700 (PDT)
Abel, 

thank you so much for your helpful explanation. I
tried and tried your example and could not get it to
compile.
Will you kindly help?

<xsl:template match="/">
    <!-- here comes your frameword for the html page
-->
    <html>
        <head>.....</head>
        .... etc ....
        <body>
             <!-- now we tell the processor what main
elements to grab
 -->
             <!-- these are children of the root -->
             <xsl:apply-templates select="PHONEBOOK"
/>
        </body>
     </body>
</xsl:template>

<!-- declaring the table, which starts for each
PHONEBOOK (only one)
 -->
<xsl:template match="PHONEBOOK">
      <!-- here comes the start of the table, you
could put it in the 
main, but this keeps it cleaner -->
      <table border="3">
           <!-- table header -->
           <tr bgcolor="lightblue">
               <th>FirstName</th>
               <th>LastName</th>
               <th>Phone</th>
           </tr>
          <!-- here we say to the processor: take
these elements that
 we 
want a rows -->
          <!-- I assume that you have added a <member>
around each 
first/last/phone, though this is not necessary -->
          <xsl:apply-template select="MEMBER" />
      </table>
</xsl:template>

<!-- declaring the row, which the processor will
automatically select 
for each MEMBER -->
<xsl:template match="MEMBER">
     <!-- here goes the row definition
            all is a client of MEMBER now -->
     <!-- an easy way to create a way so you can point
your browser
             to each member by its id or name (IE), by
using 
http://yoururl/yourpath#memberID -->
     <xsl:variable name="id"><xsl:number
/></xsl:variable>
     <tr id="member-{$id}">
            <xsl:apply-templates select="FIRST | LAST
| PHONE" />
     </tr>
</xsl:template>

<!-- declare the cells, which is any node that is a
child of MEMBER -->
<xsl:template match="MEMBER/*">
     <!-- here we select the value of the current node
(.) -->
     <td><xsl:value-of select="." /></td>
</xsl:template>
</html>


       
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow  

Current Thread