Re: [xsl] How to use xsl:key to make my XSLT program super-efficient?

Subject: Re: [xsl] How to use xsl:key to make my XSLT program super-efficient?
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 12 Mar 2025 13:11:13 -0000
On Wed, Mar 12, 2025 at 12:56:41PM -0000, Roger L Costello
costello@xxxxxxxxx scripsit:
> > Is this a change-the-element-names process or a rearrange-the-data
> > process?
> 
> Both.
> 
> The elements in the target XML will contain data that is from diverse
> elements (that have been substring'ed, length'ed, multiplied, divided,
> rounded, massaged) in the source XML.

So the essential thing is to not do both at the same time; regularizing
the source (so you can avoid special cases during processing because
you're processing a consistent pattern of input), transforming the
source (so the element names change), and deriving the result (the
"massaged" part) should be distinct stages in the code.

This helps with maintenance and documentation by helping with
comprehensibility (we're trying to do one relatively simple thing at a
time, and can define it) and it generally helps with efficiency because
you can string a lot of nigh-n or n-log-n steps together before you get
anywhere near n squared, especially for large source documents.

It also helps if you can have the code emit each stage so you can check
that it really does what you expect.

-- Graydon

--  
Graydon Saunders  | graydonish@xxxxxxxxxxxx
\xDE\xE6s ofer\xE9ode, \xF0isses sw\xE1 m\xE6g.
-- Deor  ("That passed, so may this.")

Current Thread