RE: [xsl] alternative for modes

Subject: RE: [xsl] alternative for modes
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 12 Feb 2004 14:27:10 -0500
Peter,

I don't know what you mean by "calls the other template on a particular order" (maybe typo for "in a particular order"?), but it may still be possible to do as Jeni says, since you can bind the result of a template call to a variable and interrogate it, as in:

<xsl:variable name="general-result">
  <xsl:call-template name="general"/>
</xsl:variable>

...then depending on what general-result is, you can do one thing or another (as well as copying it to the output).

This is all wonderfully vague: maybe seeing a concrete example would help? It's surprising how often straight conditionals can be avoided in XSLT by the smart use of templates ... as in

<xsl:apply-templates select="child[$condition1]" mode="condition1"/>
<xsl:apply-templates select="child[$condition2]" mode="condition2"/>

... and such like. Which seems to be in line with what you're asking.

Cheers,
Wendell

At 09:35 AM 2/12/2004, you wrote:
This is not possible I think, since the general template calls the other
template on a particular order (based on the calculation in the general
template), so I don't think it's possible in this situation.

Thanks for the tip,

Peter

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Jeni Tennison
Sent: donderdag 12 februari 2004 12:41
To: Peter Billen; xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] alternative for modes

Hi Peter,

> As I mentioned above, 'generalTemplate' can be called on several
> places in the template, because everytime I need the same
> calculations, ... on the 'root'-tag. But each time (in every other
> place), I actually need different manipulations on the 'child'-tag.

Just a thought, but depending on what the general template is doing,
it might be that you can turn around the processing, so that instead
of calling the general template with a parameter specifying the mode,
you apply templates in the specific mode and those templates call the
general template as appropriate to perform the necessary calculations.

Cheers,

Jeni


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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



Current Thread