O'Reilly logo

XSLT, 2nd Edition by Doug Tidwell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Node Types

There are seven kinds of nodes in XPath:

  • The document node (one per document)

  • Element nodes

  • Attribute nodes

  • Text nodes

  • Comment nodes

  • Processing instruction nodes

  • Namespace nodes

We’ll talk about all the different node types in terms of the following document:

<?xml version="1.0"?> <?xml-stylesheet href="sonnet.xsl" type="text/xsl"?> <!DOCTYPE sonnet [ <!ELEMENT sonnet (auth:author, title, lines)> <!ATTLIST sonnet public-domain CDATA "yes" type (Shakespearean | Petrarchan) "Shakespearean"> <!ELEMENT auth:author (last-name,first-name,nationality, year-of-birth?,year-of-death?)> <!ELEMENT last-name (#PCDATA)> <!ELEMENT first-name (#PCDATA)> <!ELEMENT nationality (#PCDATA)> <!ELEMENT year-of-birth (#PCDATA)> <!ELEMENT year-of-death (#PCDATA)> <!ELEMENT title (#PCDATA)> <!ELEMENT lines (line,line,line,line, line,line,line,line, line,line,line,line, line,line)> <!ELEMENT line (#PCDATA)> ]> <!-- Default sonnet type is Shakespearean, the other allowable --> <!-- type is "Petrarchan." --> <sonnet type='Shakespearean'> <auth:author xmlns:auth="http://www.authors.com/"> <last-name>Shakespeare</last-name> <first-name>William</first-name> <nationality>British</nationality> <year-of-birth>1564</year-of-birth> <year-of-death>1616</year-of-death> </auth:author> <!-- Is there an official title for this sonnet? They're sometimes named after the first line. --> <title>Sonnet 130</title> <lines> <line>My mistress' eyes are nothing like the sun,</line> <line>Coral is far more red than her lips red.</line> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required