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 --> 
</invoice> 

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=”http://www.w3.org/1999/XSL/Transform”> <xsl:output method=”html” /> <!-- Root template --> <xsl:template match=”/”> <HTML> <HEAD> ...

Get Special Edition Using XSLT 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.