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> ...
Get XSLT, 2nd Edition 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.