|
|
Listing A.3 displays the contents of the XSL stylesheet titleAndAuthor.xsl that extracts the title and author of the book in the file book.xml.
Listing A.3 titleAndAuthor.xsl
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:value-of select="./book/title"/> by <xsl:value-of select="./book/author"/> </xsl:template> </xsl:stylesheet>
Listing A.3 matches the following two items in book.xml:
<book> <author>Oswald Campesato</author> <title>SVG Programming</title> .... <book>
The full paths /book/author and /book/title specify the author and title, respectively, which match in the first template. Note that the concatenation of the root node '/' with the path '/.book/title' is '/./book/title,' which resolves to the path '/book/title.' Similarly, the concatenation of '/' and './book/author' is '/./book/author,' which resolves to the path '/book/author.'
|
|