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

Re: translate to XML using XSL into an HTML table

Subject: Re: translate to XML using XSL into an HTML table
From: oryann9 <oryann9@xxxxxxxxx>
Date: Mon, 6 Aug 2007 08:32:30 -0700 (PDT)
Re:   translate to XML using XSL into an HTML table
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

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.