--On Tuesday, June 15, 2004 7:09 AM +0100 [EMAIL PROTECTED] wrote:
the first query by re-writing your XSLT/XSP. For example, if your XML is large and you're doing a lot of searching through it in your XSLT, using xslt:key may vastly improve your performance.
Oh, never heard of it. I'll have a look into it tho.
Basically xsl:key (I mis-remembered the prefix before...) pre-creates an index on the table, based on whatever attributes/nodes you choose. For example, if your xml looks like:
<foo> <bar name="X">...</bar> <bar name="Y">...</bar> ... </foo>
And you need to select "/foo/[EMAIL PROTECTED]'X']", doing so directly is cheap if your XML is small. But if its big you should create a key, especially if you're doing selections of that type often. So before your templates you do:
<xsl:key name="bar_by_name" match="/foo/bar" use="@name"/>
Then when you need a piece of data you use "key('bar_by_name','X')".
You can even make up a concatenated index, if you need a multi-part search. i.e.:
<xsl:key name="foo" match="/foo/bar" use="concat(@name,'-',@type)"/>
and then select "key('foo',concat($foo_name,'-',$foo_type))". Just make sure the string you're using to separate the search elements isn't valid as part of the content of the elements.
Proper application of xsl:key can be very useful. One of our (non-AxKit) translations is taking flat database dumps with approximately 10,000 nodes and converting them to a structured format, based on the structure of our database, with approximately 145,000 nodes. Using xsltproc (which is slower than Saxon, but more widely available) that translation takes 30-40 seconds. Without keys it was taking over 10 minutes.
For the far less complex translations I'm doing in AxKit it speeds them up sufficiently that my web application is quite responsive. In some cases my app is rendering faster than our older systems, which are native Perl/mod_perl/CGI.pm based.
-David Nolan Network Software Developer Computing Services Carnegie Mellon University
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]