spacer

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

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

Inside XSLT

Developer News
Google to Shake Up Browsers With Own Launch
Mozilla's Ubquity Mashup: For The Masses?
iPhone Users Just Want to Have Fun

Accessing Node Values

You can access the value of a node with the <xsl:value-of> element. This element has two possible attributes:

The <xsl:value-of> element is always empty.

You can use the select attribute to indicate which node you want to get the value. For example, you might want to get the value of the <NAME> node in each <PLANET> element, which is the text enclosed in that node. You can do that like this:

Listing 2.4: Using <xsl:value-of>

<?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>
      <xsl:value-of select="NAME"/>
    </P>
  </xsl:template>

</xsl:stylesheet>

The value of a node that contains text is just that text, so here is the result of applying this stylesheet to planets.xml:

<HTML>
   <P>Mercury</P>
   <P>Venus</P>
   <P>Earth</P>
</HTML>

Disable-Output-Escaping Attribute
Chapter 3 goes into more detail on the disable-output-escaping attribute of the <xsl:value-of> element.

Suppose that you want to do something a little more advanced, such as transforming the data in planets.xml into an HTML table in the new file planets.html, as you saw in Chapter 1, and which you can see in Figure 2.1. You can do that now with <xsl:value-of>.

It's important to consider one issue here. There is no formal restriction on the order of the <MASS>, <RADIUS>, <DAY> and <DISTANCE> elements in planets.xml, but it's important that these elements be processed in a particular order to match the headings of the table. For that reason, I will use the <xsl:value-of> elements in the order that the HTML table needs them.


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



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Intel PDF: Virtualization Delivers Data Center Efficiency
Intel eBook: Managing the Evolving Data Center
Microsoft Article: BitLocker Brings Encryption to Windows Server 2008
Symantec eBook: The Guide to E-Mail Archiving and Management
Microsoft Article: RODCs Transform Branch Office Security
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
Avaya Article: Advancing the State of the Art in Customer Service
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Avaya Article: Avaya AE Services Provide Rapid Telephony Integration with Facebook
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Seminar: Efficiencies in Hardware/Software Virtualization
HP Webcast: Disaster Recovery Planning
Go Parallel Video: Performance and Threading Tools for Game Developers
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
IBM TCO eKIT: Your IT Budget is Under Attack, Get in Control
IBM Energy Efficiency eKIT: Learn How to Reduce Costs
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Microsoft Article: Silverlight Streaming--Free Video Hosting for All
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
HP Demo: StorageWorks EVA4400
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
The Partial Function Application in JavaScript · Creating Dynamic RSS Feeds with Ajax · Performance Optimizations for High Speed JavaScript
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Cablevision Deploys More Hotspots for Commuters · Dell Joins the Netbook Movement with its Inspiron Mini 9 · It's Official: Dell Enters the Netbook Fray

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


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