Key() & Saxon's Implmentation
Added by Anonymous about 16 years ago
Legacy ID: #5197846 Legacy Poster: Ryan (iceandrews)
From other boards, I have learned that a key() initiates the building of an index or hash table. What is the "scope" of that key's table. If the same key is use in multiple nested templates, are there multiple index tables created or is it one single index until the entire XSLT is completed. How long does the index/has table exist ? If you leave a template that has used key() & created a table, call another template and then return to continue processing, do those tables exist for the duration of the template? Even after an entire template is processed do those index tables still exist? We're trying to gauge the performance of certain transformations with multiple Lookup tables from multiple sources, being used at various levels of templates and apply-templates. We want to understand the impact and scope of the data that's index when you run the key() function so we can optimize our performance. Thanks! Ryan
Replies (2)
RE: Key() & Saxon's Implmentation - Added by Anonymous about 16 years ago
Legacy ID: #5198133 Legacy Poster: Michael Kay (mhkay)
Conceptually, for each "key definition" (that is, a set of xsl:key declarations with the same name), there is one index per document node. The index is built the first time it is used (that is, the first time key() is called to search a particular document). Usually it lasts until the end of the transformation. However, if the compiled stylesheet and the document node both outlive the transformation, then the index will also outlive the transformation - that is, several transformations applied using the same stylesheet to the same source document, either in series or in parallel, can make use of the same index. This is particularly important where an application makes use of a static lookup document and reads it using the doc() function: to ensure good performance in this case, it's important to preload the lookup document and keep it cached, perhaps using a URIResolver. Certainly the indexes outlive execution of a particular template!
RE: Key() & Saxon's Implmentation - Added by Anonymous about 16 years ago
Legacy ID: #5200030 Legacy Poster: Ryan (iceandrews)
Thank you! This provides a great bas eof information to beign structuring our transformation. Knowing that precaching the LUTs will allow them to persist through the during of the XSLT is extremely helpful.
Please register to reply