Lars Huttar wrote:
<xsl:variable name="number-rows">
<xsl:variable name="tmp"
select="/*/llcd:global-settings/llcd:setting[(_at_)name =
'number-rows']"/>
<xsl:choose>
<xsl:when test="$tmp"><xsl:value-of select="$tmp" /></xsl:when>
<xsl:otherwise><xsl:value-of select="'true'" /></xsl:otherwise>
</xsl:choose>
</xsl:variable>
But that seems pretty verbose. And it will be worse as I have multiple
settings variables with various names.
Is there a more elegant way?
Wow, Lars, if you consider that verbose I must be doing something
terribly wrong...
Assuming, all your global settings follow the same basic XPath
structure, I'd do it as follows:
<xsl:variable name="number-rows">
<xsl:call-template name="get_global_setting">
<xsl:with-param name="setting" select="'number-rows'"/>
</xsl:call-template>
</xsl:variable>
and then provide the appropriate get_global_setting named template. If
your XPath structure doesn't allow for the simple syntax above, you can
always change the "setting" parameter to a "path" parameter.
In an actual XSLT file, I would write the entire variable declaration
above on a single line to get most of the verbosity out of my face. As
an added benefit, if the retrieval method for your global settings
changes, you only have a single place to change your XSLT.
--
Steve Rosenberry
Sr. Partner
Electronic Solutions Company -- For the Home of Integration
http://ElectronicSolutionsCo.com
(610) 670-1710
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list