xsl-list
[Top] [All Lists]

optimization choose - then same call-template

2003-01-21 02:34:29
Hello friends,

enclosed a working template for generating datafields.
My question is regarding of optimization.
The unique difference of my choose-statement is that titles and labels comes 
from a xml-source or a xml-properties, the last contains the defaults.
The other three parameters which my named templates need to output datafields 
are the same.

Is there a way of doing that better?

xml-source
...
  <df name="gspaktdispo" title="activ disposition from FX">1</df>
  <df name="gspkennung" title=" ">Test</df>
  <df name="lspnr">49</df>
...
xml-properties
...
  <df name="gspaktdispo">Active</df>
  <df name="gspkennung">Id</df>
  <df name="lspnr">Countries </df>

...
xsl-transform
...
 <!-- the three parameters are inititialized from other template rule, which 
applies this rule for node df >
 <xsl:template match="df">
    <xsl:param name="pathNode"/>
    <xsl:param name="pathProperties"/>
    <xsl:param name="df" select="@name"/>
    <!-- select attribute title from xml-source with normalizing 
(delete)white-space-->
    <xsl:variable name="title" 
select="normalize-space($pathNode[.=$df]/../@title)"/>
    <xsl:choose>
      <!-- test if title from xml-source is not empty (exist and contains more 
than white-space)-->
      <xsl:when test="$title != '' "><!-- Label --><xsl:value-of 
select="$title"/>
      <xsl:call-template name="df">
          <!-- insert title from xml-source and pass parameters to generic 
template for generation of datafields -->
          <xsl:with-param name="thisTitle" select="$title"/>
          <xsl:with-param name="thisName" select="$df"/>
          <xsl:with-param name="thisPath" select="$pathNode[.=$df]/../."/>
          <xsl:with-param name="dfProperties" 
select="$pathProperties/df[(_at_)name=$df]"/>
        </xsl:call-template>
      </xsl:when>
      <!-- title from xml-properties -->
      <xsl:otherwise>
        <!-- Label --><xsl:value-of 
select="$pathProperties/df[(_at_)name=$df]"/>
        <xsl:call-template name="df">
          <!-- insert title from xml-properties and pass same parameters as 
above to generic template for generation of datafields -->
          <xsl:with-param name="thisTitle" 
select="$pathProperties/df[(_at_)name=$df]"/>
          <xsl:with-param name="thisName" select="$df"/>
          <xsl:with-param name="thisPath" select="$pathNode[.=$df]/../."/>
          <xsl:with-param name="dfProperties" 
select="$pathProperties/df[(_at_)name=$df]"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
...

Thanks,

Hans Braumüller 
Systementwickler Web-Design 
Hanse Orga AG
Oldesloer Straße 63
D-22457 Hamburg 
Telefon: (+49) 040 51 48 08-62 
Telefax: (+49) 040 51 48 08-88 
E-Mail: h(_dot_)braumueller(_at_)hanseorga(_dot_)de 

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



<Prev in Thread] Current Thread [Next in Thread>