RE: [xsl] alternative for modes

Subject: RE: [xsl] alternative for modes
From: "Peter Billen" <peter@xxxxxxxxxxx>
Date: Fri, 13 Feb 2004 17:09:07 +0100
OOPS, I got it now about FXSL!

As said, I can only use XSLT1.0 functions, but I always thought FXSL was
some kind of extension which is a layer above EXSL(.org) to be able to pass
templates as parameter. So I thought FXSL uses EXSL-functions.

I studied now how it actually works, and I was indeed wrong. It does some
neat tricks with (unique) namespaces (well for me it is :p), to accomplish
my goal.

So basically I'll have to make 2 templates: one for red output, one for blue
output, both in some unique namespace. I will pass both templates to the
giveCarsSorted-template, which will sort the cars by owner and call the
given (by parameter) template.

About the real example: sorry I really can't give it, it's a school exercise
and I don't think I'm allowed to paste my code here. However, the given
example (cars, always sort them by owner and output them first in blue, then
in red, then in ...) is almost the same of what I want to: in several
sections of my output file, I need the same ordering-strategy, but different
things has to be done by the ordered list (output in blue, red, ...) in each

Anyway, I'll try the FXSL solution out, I think I understand it, so I don't
think that will be a big problem.

Thanks for your time,


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Dimitre
Sent: vrijdag 13 februari 2004 9:40
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] alternative for modes 


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:

 XSL-List info and archive:

Current Thread