The Path to an Element

   



Finding Element Contents

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

start example
<?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>
end example

Remarks

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



   



Fundamentals of SVG Programming. Concepts to Source Code
Fundamentals of SVG Programming: Concepts to Source Code (Graphics Series)
ISBN: 1584502983
EAN: 2147483647
Year: 2003
Pages: 362

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net