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> ...

Get XML and Java™ from scratch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.