spacer

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

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

Inside XSLT

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

Now I can add another template for the next level down, which includes the <PLANET> elements. In this case, I'll just replace each <PLANET> element with the literal result element <P>Planet</P>:

Listing 2.3: Using <xsl:apply-templates/>

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

  <xsl:template match="/">
    <HTML>
      <xsl:apply-templates/>
    </HTML>
  </xsl:template>

  <xsl:template match="PLANETS">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="PLANET">
    <P>
      Planet
    </P>
  </xsl:template>

</xsl:stylesheet>

Here's the result of this stylesheet:

<HTML>
  <P>
    Planet
  </P>
  <P>
    Planet
  </P>
  <P>
    Planet
  </P>
</HTML>

As you can see, there is nothing left of the <PLANETS> element at all. All that's left is the three literal result elements <P>Planet</P> that were substituted for the three <PLANET> elements.

Omitting the select Attribute
If you omit the select attribute, then only the child nodes of the current node are processed, which does not include attribute or namespace nodes, because they are not considered children. If you want to process those kinds of nodes, you'll have to use the select attribute, as you'll see in Chapter 3.

This is all very interesting, but not too useful. It would be far better, for example, to be able to access the actual value of each element (such as the name of each planet) and make use of that data. And, of course, you can. [Continued in part 4 - Ed.]


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

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: September 26, 2001
Revised: September 26, 2001


URL: http://webreference.com/authoring/languages/xml/insidexslt/chap2/3/5.html