[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: alternative for modes

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

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
correctly.

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.

Cheers,

Dimitre Novatchev
FXSL developer, 

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html



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

<streetrace> 
	<car> 
		<owner> ...</owner>
		...
	</car> 
	<car> 
		<owner> ...</owner>
		...
	</car> 
	...
</streetrace> 

Now imagine you want to print out all the cars of the streetrace: first
all
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
code).
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'"/> 
	</xsl:call-template> 
	<!-- in red !--> 
	<xsl:call-template name="giveCarsSorted"> 
		<xsl:with-param name="mode" select="'red'"/> 
	</xsl:call-template> 
</xsl:template> 

<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
$mode
	</xsl:apply-templates> 
</xsl:template> 

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

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

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
is
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
one
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,

Peter


 


__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.