Retrieving Attributes

Returning to the XML document instance in Listing 2.1, you’ll notice that the <invoice> element contains two attributes; num and invoiceDate. To recap, the element looks like this:

<invoice num="2317" invoiceDate="07-09-01"> 
   <!-- ...other XML data --> 

In this next style sheet, you would like to retrieve and display these attribute values in the browser window. Listing 2.5 shows the style sheet.

Listing 2.5. This Style Sheet Builds on the Previous by Retrieving the num and invoiceDate Attributes from the Source Document
 <?xml version=”1.0” ?> <xsl:stylesheet version=”1.0” xmlns:xsl=””> <xsl:output method=”html” /> <!-- Root template --> <xsl:template match=”/”> <HTML> <HEAD> ...

Get Special Edition Using XSLT now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.