Skip to main content

XSLT: Programmer's Reference, 2nd Edition

XSLT: Programmer's Reference, 2nd Edition

Michael Kay

ISBN: 978-0-764-54381-4

May 2001

1008 pages

Select type: Paperback

Product not available for purchase

Description

What is this book about?

This compact, relevant, updated version reflects recent changes in the XSLT specification and developments in XSLT parsers. The material on tools and implementations has been revised; so too have all the examples. It also includes a new chapter on writing extension functions.

XML has firmly established itself as the universal standard for managing data for the web and is now being implemented on a wide scale.

XSL (eXtensible Stylesheet Language), a vital companion to XML, is used for two main purposes: to format or style XML data so that it can be displayed in a browser and to transform XML data (XSLT). When you transform an XML document, you manipulate the data into a new structure, for example, re-ordering the data. This enables the same data store to be used in an unlimited number of ways. XSLT is a flexible, customizable, and cross-platform language.

XSLT is a notoriously difficult language to understand, but this book, while being a complete reference to the recommendation, will also give code examples showing how it all ties together and can be effectively employed in a real-world development scenario.

What does this book cover?

In this book, you'll find the following topics covered:

  • The rationale behind XSLT: What is it for?
  • The XSLT processing model
  • Design patterns and stylesheet structure
  • A full reference to the XPath and XSLT languages
  • The use of XSLT with worked examplesCurrently available XSLT processors - updated to reflect recent advances in XSLT parser technology
  • Coverage of proposed specification enhancements

Who is this book for?

This book is for programmers already using XML to organize their data in applications and for those who want to use the power and compatibility of XSLT to improve the display of their data. The book is in three parts: a detailed introduction to the concepts of the language, a reference section giving comprehensive specifications and working examples of every feature, and an exploitation guide giving advice and case studies for the advanced user.

Introduction.

Chapter 1: XSLT in Context.

Chapter 2: The XSLT Processing Model.

Chapter 3: Stylesheet Structure.

Chapter 4: XSLT Elements.

Chapter 5: Expressions.

Chapter 6: Patterns.

Chapter 7: Functions.

Chapter 8: Writing Extension Functions.

Chapter 9: Stylesheet Design Patterns.

Chapter 10: Worked Examples.

Appendix A: Microsoft MSXML3.

Appendix B: Oracle.

Appendix C: Saxon.

Appendix D: Xalan.

Appendix E: Other Products.

Appendix F: TrAX: The Transformation API for XML.

Glossary.

Index A – Elements.

Index B – Functions.

Index C – General.

Download source code for this book
Download
Saxon XSLT parser
Download
ChapterPageDetailsDatePrint Run
0Table of Contents: page numbers for Chapter 7 (pages xxii-xxvi)

Thanks to Dan Glickman for spotting this one. In the Table of Contents, the page numbers for the sections namespace-uri through Summary , are all one page out (one page less than they should be)

05-Jun-011

230Closing tag in wrong place.

Thanks go to Viktor Heimonen for pointing this one out.

In the code block at the top of the page, the closing tag is at the end of the second line. It should be at the end of the third line, after the namespace declaration.

22-May-011

28URI is Uniform Resource Identifier

Thanks to Eugene Morozov for submitting this correction.

At the beginning of the last paragraph, the book says, Namespaces are identified by a Unique Resource Identifier (URI). URI is a Uniform Resource Identifier , not a Unique Resource Identifier .

03-Dec-011

36Missing guillemets

Second to last line before final code block:

select= book/author/first-name

&npsp;&npsp;&npsp;&npsp;...should be expressed

?select= book/author/first-name ?
(using guillemets)

18-Sep-021

58XPath tree diagram

Thanks to Paul Larson for spotting this.

In the middle row of the XPath tree diagram in the centre of the page, the centre cells of the second, fourth, and sixth boxes should read noun , verb, and noun , respectively.

30-May-011

82Incorrect page reference

Thanks again to Gustaf Jarnling for spotting this one.

The first paragraph reads:

... how to use modes are in Chapter 4, page 323 and an example ...

The section Using Modes is actually found in Chapter 4, page 320

22-May-011

91Incorrect page reference for Literal section

Thanks to Mike Snowden for spotting this.

Towards the bottom of the page, there is a page reference for a section entitled Literal . It should say page 389, not page 388

24-May-011

93Extra angle bracket in code block

Thanks to Mike Snowden for pointing out this one.

In the code block at the foot of the page, there is a surplus closing angle bracket at the end of the third line that shouldn't be there.

24-May-011

95 elements should be self-closing

Thanks to Derrf Seitz for submitting this erratum. The two <xsl:value-of> elements on this page should be self-closing (that is they should end ../>)

08-Oct-011

95xsl:value-of select attributes

Thanks to Richard Day for spotting this.

When the closing tags were added to the <xsl:value-of> elements, this seems to have mangled the end of the select attributes. These elements should read:

<xsl:value-of select= name($months/*[position()=$mm]) />

and:

<xsl:value-of select= name(xx:node-set($months)/*[position()=$mm]) />

02-Dec-021

101Incorrect output shown

Thanks to Dan Glickman for this. The output shown on the page says XSLT 1.1 Programmer's Reference.. . It should say XSLT Programmer's Reference..

25-Jun-011

104Incorrect output shown

Thanks to Dan Glickman for this.

The output shown on the page says XSLT 1.1 Programmer's Reference.. . It should say XSLT Programmer's Reference..

25-Jun-011

113Spurious page reference information printed

Thanks to Gustaf Jarnling for spotting this.

At the bottom of the page, we have the text ..calls this facility Literal Result Element as Stylesheet113. The 113 shouldn't be there, please ignore it!

30-May-011

114Incorrect page reference

Thanks again to Gustaf Jarnling for alerting us to this.

books.xml is listed on page 77, not 59 as we state towards the bottom of the page.

30-May-011

121Typo in figure
Thanks to Dan Glickman for spotting this.

There's a typo in the figure at the bottom of the page. As the element is <price>, the source tree should say price, not Price
25-Jun-011

125Date.toString() should be Date:toString()

Thanks to Viktor Heimonen for spotting this one.

At the top of the page, in the italicized background box, there is a typo. Where it says Date.toString(), it should say Date:toString()

30-May-011

128Page reference incorrect

Thanks to Dan Glickman for spotting this.

There is a page reference to 544. It should say 545.

25-Jun-011

128img tag should be self-closing

Thanks to Erik Abbink for submitting this correction.

The <img> tag in the code on this page should be self-closing.

15-Nov-011

133Incorrect implements-prefix attribute

Thanks go to Robin Meade for bringing this one to our attention.

In the code block towards the foot of the page, we've incorrectly used an implements-prefix= Math attribute for the <xsl:script> element. It should be implements-prefix= Date

15-May-011

134Typo in namespace declaration

Thanks to Robin Meade for spotting this one.

The first example on this page declares a js namespace but then goes on to use an ms namespace. The namespace declaration should say:
xmlns:ms= javascript:my-extensions

15-May-011

139Incorrect parentheses in code example

Thanks again to Viktor Heimonen for pointing out this one.

In the gray code block, the parentheses in the second line are incorrect. The line should read:
starts-with(system-property('xsl:vendor'), 'xalan') >

30-May-011

142Whitespace characters haven't printed

The characters denoting whitespace characters at the bottom of the page haven't printed. There should be a newline character at the end of each line except the last, a tab at the beginning of each line except the first and the last, and three spaces after the tab before each of the three lines between the place-of-work tags.

30-Apr-011

143Some whitespace characters have not printed

In the code block at the top of the page, there should be newline characters (in black on a gray background) at the end of three lines starting with thge place-of-work oopening tag. The characters at the end of the second and third lines should be the same as the first (that is, white newline characters on a black background).

30-Apr-011

157Page reference incorrect

Thanks to Dan Glickman for spotting this.

There is a page reference to 532. It should be to 533

25-Jun-011

167Example code incorrect

Thanks to Al Cadalzo for submitting this erratum.

The second line in the first block of example code on this page is incorrect. It should read:
<xsl:attribute name= border >2</xsl:attribute>

15-Oct-011

169Output in code example wrong.

Thanks to David Nesbitt for alerting us to this mistake.

In the second code box on the page, the width attribute shown in the output is incorrect. It should be <table ns001:width= 200 ...

03-Sep-011

185Correction to code at top of page

Thanks to Ian Limn for supplying us with this correction.

The third line needs to read:
<xsl:sort select= count(LINE) data-type= number />, because the sort type defaults to text . Without this correction, the code will not work as intended with speech longer than 9 lines

12-Nov-011

199Typo in code

Thanks to Dan Glickman for spotting this.

In the code block towards the bottom of the page, it should say <xsl:variable name= node-id ..(not note-id )

25-Jun-011

245Missing closing tag characters.

At the end of the single line xsl:key code block in the middle of the page, there is a missing /> at the end of the line.

30-Apr-011

258Page references incorrect

Thanks to Dan Glickman for spotting this.

There are page references to 530 and 536 on the page. They should be to 531 and 537 respectively

25-Jun-011

263Page reference incorrect

Thanks to Dan Glickman for spotting this.

There is a page reference to 559. It should be to 560.

25-Jun-011

319First line of code printed twice

Thanks to Erik Abbink for submitting this correction. The first line of code has been erroneously printed twice.

15-Nov-011

324Default value of disable-output-escaping is no

Thanks to David Nesbitt for spotting this error.

The text on line 3 of the paragraph after the bullets should read:

The default value is <<no>>. The value <<yes>> may be ignored in some
circumstances...

03-Sep-011

337Incorrect page reference

Thanks to Amin Mohadjer (Aditi) for pointing out this one.

In the first paragraph on the page, there is a incorrect page reference to a fully worked example in Chapter 7. This should read 555, not 553.

13-Jun-011

340Page reference incorrect

Thanks to Dan Glickman for spotting this.

There is a page reference to 544. It should be to 545.

25-Jun-011

341Page reference incorrect

Thanks to Dan Glickman for spotting this.

There is a page reference to 559. It should be to 560.

25-Jun-011

358Symbol not printed

An R in circle , ?, hasn't printed on this page. The last sentence of the third paragraph from the bottom should read: I find it helpful to think of an AbsoluteLocationPath <</X>> as an abbreviation for an imaginary expression <<?/X>>, and <</>> as an abbreviation for <<?>>, where <<?>> represents the document root node.

30-Apr-011

360Non-trivial AndExpr consists of TWO or more EqualityExpr

Thanks to SATO Naoki for submitting this error. At the bottom of the page the book states, A non-trivial AndExpr consists of one or more EqualityExpr.. . It should say A non-trivial AndExpr consists of two or more EqualityExpr..

05-Nov-011

361Strings are converted to Boolean true if their length is non-zero

Thanks to Bradley Grainger for spotting this one.

In the second to last example in the Examples table, the book should say ...converted to the Boolean true if their length is non-zero not if their length is zero

17-Jul-011

417"comparing" should read "converting"

Thanks to Bradley Grainger for alering us to this one.

In the sixth line up from the bottom of the page, we state ...the result of comparing the string operand... . This should read ...the result of converting the string operand...

17-Jul-011

426Page reference incorrect

At the bottom pf the page, there is a page reference to an example in Appendix A. This reference should read 721, not 706.

30-Apr-011

452id() is a core XPath function

Thanks to Jeff Yemin for submitting this. In the table, the id() function has a cross next to it. As it is part of the XPath core functions, it should have a tick next to it.

03-Oct-011

458"Format" section in wrong place

Thanks to Ant??nio Ferreira for alerting us to this one.

The Format section for the contains function is in the wrong place. It should be below the Defined in section.

17-Jul-011

504Missing double quote in example tag

Page 504, middle of the page.

Reads: <xsl:for-each select=key('country-group', @country) >

Should be: <xsl:for-each select= key('country-group', @country) >

Note the missing double quote.

03-Apr-021

520Expessions in last paragraph

Thanks to Stephen Ng for submitting this correction. The last paragraph on the page should read:

In all these cases, the safest approach is not to write <<name()!='description'>>, but rather to write <<local-name()!='description' and namespace-uri()=''>>

13-Dec-011

530Missing ']' mark in code sample

In copies of this book printed prior to March 2002, there is a missing closing square bracket in the fourth code example. i.e.:

????????<xsl:for-each select= *[not(self::notes) >

should be:

????????<xsl:for-each select= *[not(self::notes)] >

10-Oct-021

631Page reference incorrect

Thanks to Dan Glickman for spotting this.

There is a page reference to 606. It should be to 604.

25-Jun-011

657Diagram incorrect

Thanks to SATO Naoki for submitting this correction.

In the diagram at the bottom of the page, the first line of the bottom table should read FAM ID=F1, not INDI ID=I1

20-Nov-011

706Page reference error.

Thanks to Eric Smith and Gustaf Jarnling for spotting this. Halfway down the page, where a page reference should be, it says Error! Bookmark not defined due to a production error. It should say 107.

09-May-011

752OracleXML Utility is now called Oracle XML SQL Utility

Thanks to SATO Naoki for pointing out that the OracleXML utility is now called the Oracle XML SQL Utility.

22-Nov-011