Re: [xsl] Comparing nodes in axis

Subject: Re: [xsl] Comparing nodes in axis
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 21 Dec 2004 09:53:59 GMT
Note in all these you have multiple occurrences of (//menu)[$pos]) this
is (on the face of it) a massively expensive operation: search the
entire document to an arbitrary depth, looking for menu nodes, and then
select the $pos'th menu.

It may be that your processor spots that the same expression is being
used multiple times and optimises away some of the cost but it's still
going to take at least one very slow search. You could at least help it
by saving <xal:variable name="thismenu" select="(//menu)[$pos])"/>
and using $thismenu instead, and possibly (depending on the details of
your stylesheet) you should get rid of the $pos parameter altogether and
just use the $thismenu parameter. Often when people coming to xslt ffrom
other languages pass around an integer parameter and repeatedly re-index
into some node list, they are just used to the less natural data
structures in those languages, in xslt if a template depends on anode,
you can pass that node in as a parameter, you don't have to pass in an
integer and make it select the node.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread