Re: [xsl] test multiple parameters or just write a new template?

Subject: Re: [xsl] test multiple parameters or just write a new template?
From: Dan Vint <dvint@xxxxxxxx>
Date: Thu, 11 Jan 2001 08:37:18 -0800 (PST)
Not sure of your setup, but there is the <xsl:import> and <xsl:apply-imports>
that might work for some of what you are trying to do. Basically you
put the "standard" processing in a template and store that in an outside file.
You then import that file and create another template of the same name in the
file that does the import. You can add functionality to the template and then
use the <xsl:apply-imports> to then bring in the standard processing.

..dan

> 
> Hi,
> 
> I've been working with XSL for a few months now and can do must things. 
> There is one issue that crops up a lot, though, and I'm not sure of the 
> best way to solve it.
> 
> I am doing lots of template calls so that I can make my code as flexible as 
> possible. Often I find that I could reuse a template, except I need to 
> alter it slightly. Say I can't do this by simply overriding it, because I 
> need it to function slightly differently in the same file. Is it better to 
> parameterize one template and test the parameter to select desired 
> behavior, or should I just be writing an entirely new template? Sometimes 
> the behavior differs in four ways, say, and the template has other 
> parameters, so there gets to be a lot of testing and parameter-passing 
> going on.
> 
> I'd send the code, but there's lots of other stuff going on in it, so maybe 
> the example below will be enough.
> 
> Example:
> 	I have a template that creates an HTML form allowing users to create a 
> hyperlink in their user account.
> 	The template is in its own stylesheet and gets imported whenever I need it.
> 	Generally the importing stylesheet uses this Hyperlink template two or 
> more times (so I can't do a blanket override of the 		behavior I need to 
> change)
> 	It has four text fields: link name, link title, URL, and icon.
> 	That works for one case.
> 	In another case I want the URL text field to be a drop down list of user's 
> exising links, but other fields remain the same.
> 	I already have to pass in two parameters and execute a choose statement to 
> determine whether I'm creating a new link or 	modifying an existing one. 
> This is why I'm not sure if I should do yet another test or just write 
> another template.
> 
> Any thoughts would be appreciated.
> 
> Cheers,
> Sue
> 	
> 	
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


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


Current Thread