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

Re: Only output element when parameter value is not eq

Subject: Re: Only output element when parameter value is not equal to blank (or null)
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 01 Feb 2007 14:37:25 +0100
Re:  Only output element when parameter value is not eq
Florent Georges wrote:
You can make your stylesheet miles simpler and shorter by
using a different approach. Instead of tons of parameters,
use something extensible, like an XML structure

It simplifies the stylesheet, yes, but it is not always what you want. You can want to provide a lot of parameters, settable from the command line interface of several processors, without requiring intalling other piece of software. In this case, defining (even a lot of) parameters taking only string values is what you want.

Regards,

--drkm

One additional thought I left out is, to ease your development, to use tokenized parameters. But you are right, depending on your target system, and whether you can control how the xslt is called, you may and up with an unwieldy garden of parameters. We can't always have what we want.


But the way I look at it, seeing the OP's code, it looks awfully much like a hard maintainable piece of xslt. There are many ways to ease it, especially with the help of XSLT 2. And if you can't use XML or tokenized parameters, you can still keep all the logic around the huge amount of parameters together by using one additional variable (not parameter) that looks like my suggested param. The very least you will gain is: 20+ less xsl:if statements and much more readable/maintainable code.

Of course, modularizing your code, and how much time you want to spend on it, is all a matter of taste. Here's an upgraded example that illustrates my thoughts, leaving the OP's original parameters intact:

<xsl:param name="catalogName" />
<xsl:param name="productId" />

<xsl:variable name="key-settings">
  <setting name="MASTERCATALOGNAME" value="{$catalogName}" />
  <setting name="PRODUCTID" value="{$productId}" />
  ....
</xsl:variable>

<xsl:template match="/" >
.....

rest of the templates remain the same, see my earlier post on it, except for this one (see the slight change in the match):


<xsl:template match="setting[normalize-space(@value) != '']"> <Key name="{@name}" type="string"> <xsl:value-of select="@value" /> </Key> </xsl:template>


Cheers, -- Abel Braaksma

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.