Re: follow up re: key execution speed
Hi Mike, > The trick is this: while I have been advised that keys are speed for > any lookup that will be performed more than once in a transform, my > situation is a little more complicated. I only do this lookup once > per transform, but I perform this transform many times (thousands!) > on different source documents. I was hoping to get the speed benefit > of the key across these multiple transformations. If the multiple transformations happen in the same process, then perhaps you can adjust your XSLT to pull in the thousands of source documents sequentially, and perform the transformation of each. That way the key is produced once, used multiple times, and you'll get the benefit of the key. Otherwise, there is no point in using the key, and I imagine it makes performance worse because of the memory usage. Instead you may as well search for the relevant ZIP and DEALER information using an XPath. However, the real problem is that parsing big documents takes time. But there are a couple of other things that might speed things up. First: rather than having big Zips.xml and Dealers.xml document, split them down into multiple XML documents (using XSLT if you like), indexed by their values. So for example, Zip.10001.xml being: <ZIP rc="2" /> You can then quickly access the value that you want using: document(concat('Zip.', $ZIP, '.xml'))/ZIP/@rc The parse of Zip.10001.xml won't take long because it's so small. Alternatively, if you don't want to have to manage all those files, put all the information into a database and use a specialist EntityResolver (or whatever it's called) so that when you use document('') with a 'zip' protocol, it checks the database for something with that zip and returns a document that looks like the above. (Or create an extension function in Java to retrieve the Zips from the database.) Another thing that you may be able to do is to pre-parse the Zips.xml and Dealers.xml documents, hold them as DOM Document objects and either pass them in as parameters to the stylesheet or again write an EntityResolver that proffers those DOM Document objects on demand. That way they only get passed once. Again, the key will make no difference since the lookup only gets done once per transformation, but you'll have got around the big barrier of parsing the documents each time. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format