RE: [xsl] anyway obvious way to speed this tranfrom up?

Subject: RE: [xsl] anyway obvious way to speed this tranfrom up?
From: "Ragulf Pickaxe" <jawxml@xxxxxxxxxxx>
Date: Tue, 06 Jan 2004 15:00:26 +0000
Hello again Ray,

Been away for some, but I hope what I write is of some use.

Date: Fri, 2 Jan 2004 13:34:56 -0800
...

I need all the parameters in the template that is called by the one that is called first. What does splitting it up do for me?

From what I could see, it would speed it up.

The structure of your programme is, as far as I remember, this:


You have (at least) 3 templates, A, B and C. A calls B, which calls C
You have 2 sets of parameters X1 and X2. The sets are composed of the same variables (parameters), only the values in the variables (parameters) are different.


The choice of which to use is made in the template A.
Depending on your test, you send either the set X1 or X2 to B. From B you send the same set to C.


The test condition was
Condition 1: "name=/inputDocument/header/name[4]" -> set X1
Condition 2: "name=/inputDocument/header/name[5]" -> set X2

So:

Template A:
for-loop:
 if condition 1:
   Call B with loads of parameters (set X1)
 if condition 2:
   Call B with loads of parameters (set X2)
end loop

Template B:
 Get parameters
 Do something
 Call C with same parameters

Template C
 Get parameters
 Do something


What I proposed was something like:


Global variables:
Set X1
Set X2

Template A
for-loop:
 if condition 1:
   Call B1
 if condition 2:
   Call B2
end loop

Template B1
 Uses Set X1
 Do something
 Call C1

Template B2
 Uses Set X2
 Do something
 Call C2

Template C1
 Uses Set X1
 Do something

Template C2
 Uses Set X2
 Do something

This way, you would not have to set, then pass, parameters all the time. Especially with so many of them, and the templates being called so many times (for-each). You could also still have one B and one C template, passing a single parameter telling which of the two sets of variables to use.

Normaly the scetched solution would be unmanagable as you would have to make the changes on both C1 and C2 if you want to change something on that level, but as you are creating the XSL automatically, then that is not a problem.

This is just seen from my point of view and I don't know if it is applicable to you. Michael Kay pointed something completely different thing out to you.

> As the values of the parameters are hardcoded, and only dependent on the
> two
> conditions, you would now not need to throw all these parameters at each
> call. If you want, you can create global variables at the top of the xsl
> document to hold the values.

I could use those for the constants or maybe pass them in as arguments to
the transform.


I don't know if you answered it yourself, but I have now tried to illustrate my thoughts more.


Regards,
Ragulf :)

_________________________________________________________________
Få alle de nye og sjove ikoner med MSN Messenger http://messenger.msn.dk/


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread