Checking XPath Expressions

Probably the most common bugs in style sheets are related to XPath expressions where templates do not correctly walk the document tree. As a result, you might not be selecting the element or attribute you think you are. To solve this, you must be able to examine the structure of your document. Once you’ve narrowed down an offending line using the techniques presented earlier, the basic process is to

1.
Examine the XPath expression (usually a step pattern).
2.
Compare the pattern to the structure of the source document.

Tip

Even with dynamically generated documents, this is easy to do if you have a formal DTD or schema. Unfortunately, if you are not using a DTD, the only example of structure is the document itself. ...

Get Special Edition Using XSLT 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.