O'Reilly logo

XML and Java™ from scratch by Nicholas Chase

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting Specific—Using XPath

This is all well and good, but so far there's nothing that we couldn't have done with CSS, and with a lot less complication. One thing we can't do with CSS, however, is to actually select and transform the data before we display it. Let's start with selecting specific pieces of data. In Listing 2.11, we'll start by just listing the vendor names.

Listing 2.11. catalog.xsl: Selecting Specific Data
0:<?xml version="1.0"?>
1:<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
2:
3:<xsl:template match="/">
					4:       <xsl:apply-templates/>
					5:</xsl:template> 6: 7:<xsl:template match="*"> 8: <xsl:apply-templates/> 9:</xsl:template> 10: 11:<xsl:template match="text()"> 12: <xsl:apply-templates/> 13:</xsl:template> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required