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="{(_at_)name}" type="string">
<xsl:value-of select="@value" />
</Key>
</xsl:template>
Cheers,
-- Abel Braaksma
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--