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

optimization choose - then same call-template

Subject: optimization choose - then same call-template
From: "Braumüller, Hans" <H.Braumueller@xxxxxxxxxxxx>
Date: Tue, 21 Jan 2003 10:34:29 +0100
xml optimization
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[@name=$df]"/>
        </xsl:call-template>
      </xsl:when>
      <!-- title from xml-properties -->
      <xsl:otherwise>
        <!-- Label --><xsl:value-of select="$pathProperties/df[@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[@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[@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.braumueller@xxxxxxxxxxxx 

 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.