[xsl] Re: controller stylsheet. performance, best practices question

Subject: [xsl] Re: controller stylsheet. performance, best practices question
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Thu, 24 Apr 2003 13:22:48 +0200
"Braumüller, Hans" <H.Braumueller@xxxxxxxxxxxx> wrote in message
news:EB6EC71285FAC6469C0F41B476F5AAA1026B66@xxxxxxxxxxxxxxxxxxxxxxxxxxx

> I cannot figure out how the template xyzPage with mode="switch" is getting
involved when i call
>
> from template match="/" following in my switch.xml parameter p with xyz:
>
> <xsl:apply-templates
> select="document('switch.xml')/switch/*[name()=$p]">
>   <xsl:with-param name="current-node" select="."/>
> </xsl:apply-templates>
>

I think Mike meant:

<xsl:apply-templates mode="switch"
  select="document('switch.xml')/switch/*[name()=$p]">
  <xsl:with-param name="current-node" select="."/>
</xsl:apply-templates>



> Then i am in node xyz in switch.xml
>
> I do not see how template xyzPage with mode="switch" is applied then
> ?

if there is only one template that matches an "xyzPage" element, it will be
instantiated by the code above.

The code above achieves instantiating a template dynamically based on the
node that is matched by it. The node name itself is passed as a parameter.

So, instead of writing an unlimitedly long <xsl:choose> and having to update
it with new cases every time a new template is added, the code above does it
just in 4 lines -- once and forever.

This is the idea -- in case it is not clear there's a more detailed
explanation and many, many examples at:

http://fxsl.sourceforge.net


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL




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


Current Thread