Yup, the // construct is slow no matter which way you look at it, and no
matter what processor you use. It essentially forces to processor to
re-scan the whole document every time you use it, and it's a very difficult
thing for us to try to optimize.

One general strategy to avoid it is to build your application from the
bottom up instead of the top down.  Commonly when people start with
stylesheets, they program them like other procedural languages, which is
now how stylesheets work best.  Focus on writing template rules for each of
the specific bits of data you want, that just process that data.  Then
write the higher level templates that actually start the processing from
the root and organize your structure.  Also, don't worry about having too
many templates - while there is a maintenance cost with more xslt code,
beginning users often try to cram too much into a couple of templates
instead of spreading the processing out.  If you write one big complex
template that forces all the output directly and uses lots of esoteric
'absolute' selects like // the processor can't optimize it.  If you break
the problem up into chunks, and then write each template rule
independently, we can optimize better - and your stylesheet is more
flexible usually too.

XSLT overall still needs to have more tutorials and advanced users and
tools and such to help guide everyone into *efficient* ways to write
stylesheets - a process that will take time.

- Shane

Reply via email to