dita-ot/dita-ot — pull request #1672 by eerohele (2014-04-17 13:19:20+00:00)
Title: Performance optimizations for the PDF2 plugin

A strew of performance optimizations for the PDF2 plugin.

Using [the DITA 1.2 specification](http://docs.oasis-open.org/dita/v1.2/spec/DITA1.2-spec.zip) as a test document, these optimizations improve the performance of the `transform.topic2fo.main` stage by something like 70% percent (Saxon profiles: [before](https://dl.dropboxusercontent.com/u/83562/spec-before.html), [after](https://dl.dropboxusercontent.com/u/83562/spec-after.html)). In a large document with many figures, tables, and footnotes as well as links that refer to those elements, the improvement might be even more significant.

The results are mostly achieved by using XSL keys instead of the `//` axis and a combination of XSL keys and [XPath 2 node comparison operators](http://www.w3.org/TR/xpath20/#id-node-comparisons) instead of the `preceding::` axis or the `` element.

If you'd like me to provide additional test documents, I can do that, but I just wanted to submit this PR already so that you can take a look at the changes. So far I've tested the changes on the DITA 1.2 specification and the DITA-OT User Guide, as well as a customer document with many tables, figures, and links to both. In all cases, the XSL-FO code remains identical after the changes I've made.

This PR also introduces the `class` XSL key, which can be used to look up DITA element by their `@class` attribute value by doing something like `key('class', 'topic/topic')`, as suggested by [Dr. Kay](https://twitter.com/michaelhkay/status/365439206253789184). This key could be used for further performance improvements and cleaner code.