RE: [xsl] alternative for modes

Subject: RE: [xsl] alternative for modes
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 13 Feb 2004 00:40:08 -0800 (PST)

I do not understand what really is the problem. I am inclined to believe
that if it is that difficult to describe this problem, then most probably
you do not have a problem at all?

Or could you, please, provide a really concise and compact example that
illustrates the problem well?

This is a very frequent situation on this list. There are a lot of very
knowledgeable people, who can help and are willing to help.

When this help is not given, it is mostly due to the fact that the OP
couldn't express the problem well so that it would be understood

Most people hate guessing and even Jeni is sometimes clueless... :o)

Now, my guess is that you need to be passed as parameter a list of actions
(templates) to be performed. This is exactly what FXSL empowers you to do
with ease.

Waiting for a well-defined problem.


Dimitre Novatchev
FXSL developer, -- the home of FXSL

----------- Peter Billen wrote:
 RE: [xsl] alternative for modes | RE: [xsl] alternative for modes  
Oki I think it's time for an example :) Imagine:

		<owner> ...</owner>
		<owner> ...</owner>

Now imagine you want to print out all the cars of the streetrace: first
in red, then in blue, sorted by the owner of the car(in my example of
course, everything is a bit more complicated, especially the sorting
The best I came up with, is the following:

<xsl:template match="streetrace> 
	<!-- print cars in blue !--> 
	<xsl:call-template name="giveCarsSorted"> 
		<xsl:with-param name="mode" select="'blue'"/> 
	<!-- in red !--> 
	<xsl:call-template name="giveCarsSorted"> 
		<xsl:with-param name="mode" select="'red'"/> 

<xsl:template name="giveCarsSorted"> 
	<xsl:param name="mode"/> 

	<xsl:apply-templates>  // this will go to each <car>-element
		<xsl:sort select="car/owner"/>  // sort on <owner> in <car>
		<xsl:with-param name="mode" select="$mode"/>  // propagate

<xsl:template match="car"> 
	<xsl:param name="mode"/> 

	<xsl:if test="$mode = 'blue'"> 
		<font color="blue"> <xsl:value-of select="."/></font><br/>
	<xsl:if test="$mode = 'red'"> 
		<font color="red"> <xsl:value-of select="."/></font><br/>

I hope I didn't make any big mistakes, since I haven't tested it myself.

In my opinion the problem is: I need the same sorting more than once, so
it's a good idea to put it in a separate template (the sorting in my code
a bit more complicated). However, all the situations where I need the
sorting, DO NOT depend on any specific value(s) of the <car> -element or
or more of his children. So I THINK creating 'conditional templates' won't
help since there is no condition, which can be deduced from the
tree-structure, at all.

Thanks for your time,



Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.

 XSL-List info and archive:

Current Thread