[xsl] Best Practice: How to include conditional snippets of xsl

Subject: [xsl] Best Practice: How to include conditional snippets of xsl
From: "Braumüller, Hans" <H.Braumueller@xxxxxxxxxxxx>
Date: Thu, 3 Apr 2003 13:11:52 +0200
Hello friends,

i hope you are feeling good besides of the war.

My following question is regarding optimization for coding for following situation:

I am on case1:

then I have noticed that you cannot do
<xsl:if test="$case = case2"><xsl:call-template name="transformSomething" >
when you do not have defined the named template "transformSometing" for case1
because you don´t need it there.

That must be of the funtional nature of this language, i imagine that the xsl-processor reserved adresses for all templates before starting to transform?

I do know now following:

file1 - specific (SITUATION case1)
<xsl:template name="Case2">
<!-- do nothing -->
</xsl:template>

file2 - specific (SITUATION case2)

<xsl:include href="case2.xsl"/> 
<xsl:template name="Case2">
  <!-- Parameter getting from file3 frame.xsl -->
  <xsl:param name="case"/>
         <xsl:call-template name="transformSomething">
           <xsl:with-param name="case" select="$case"/>
        </xsl:call-template>
  </xsl:template>

both included the generic file 3 frame.xsl
with folowing statement: 
<xsl:if test="$case = case2"><xsl:call-template name="Case2" >
<xsl:with-param name="case" select="$case"/>

The named template "transformSomething" is only defined in case2.xsl included only by file2

Do you think there are other  more elegant or better ways for operating with conditional snippets of code?

Thanks for your input,

Peace,
 
Hans Braumüller 
-- + -- 
Mail Art Not War
http://crosses.net

 

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


Current Thread