spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / authoring / languages / xml / insidexslt / chap2 / 4 To page 1current pageTo page 3To page 4
[previous] [next]

Inside XSLT

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Figure 2.1, Planets.html in the Internet Explorer
Figure 2.1 Planets.html in the Internet Explorer.

To create the HTML table you see in Figure 2.1, then, I'll first match the <PLANETS> element, and then replace it with the HTML needed to create the HTML table itself. The <PLANETS> element is a child element of the root node, and because you can refer to the root node as "/", you can refer to the <PLANETS> element directly as "/PLANETS", without having to first use a template for the root node. This is an example of an XPath expression, and you'll see many more of them in Chapter 4.

Here's how I start the HTML table by matching the <PLANETS> element directly as "/PLANETS"-note that I use <xsl:apply-templates> to apply templates to any child nodes of <PLANETS>:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/PLANETS">
    <HTML>
      <HEAD>
        <TITLE>
          The Planets Table
        </TITLE>
      </HEAD>
      <BODY>
        <H1>
          The Planets Table
        </H1>
        <TABLE BORDER="2">
          <TR>
            <TD>Name</TD>
            <TD>Mass</TD>
            <TD>Radius</TD>
            <TD>Day</TD>
          </TR>
          <xsl:apply-templates/>
        </TABLE>
      </BODY>
    </HTML>
  </xsl:template>
        .
        .
        .

Each <PLANET> child node has a <NAME>, <MASS>, <RADIUS>, and <DAY> child node, and I want to process them in that order so that they are added to the HTML table to match the table's headings. To specify the order in which they should be processed, I'll put the <xsl:value-of> elements in that order:


home / authoring / languages / xml / insidexslt / chap2 / 4 To page 1current pageTo page 3To page 4
[previous] [next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

Created: October 4, 2001
Revised: October 4, 2001


URL: http://webreference.com/authoring/languages/xml/insidexslt/chap2/4/2.html