Re: [xsl] Simplify HAIRY xslt

Subject: Re: [xsl] Simplify HAIRY xslt
From: Marcus Andersson <marcus@xxxxxxxxxx>
Date: Fri, 14 May 2004 20:21:13 +0200
Wendell Piez wrote:

You can isolate this logic further:

  <xsl:template name="rule">
    <xsl:param name="uri"/>
    <xsl:variable name="prefix" select="../@prefix"/>
    <xsl:variable name="uid-assign">

      <res:when test="*[name() = '{$prefix}:rule']">
        <xsl:text>{*[name() = '</xsl:text>
        <xsl:value-of select="$prefix"/>
        <xsl:value-of select="$prefix"/>


<xsl:element name="{$prefix}:rule" namespace="{$uri}">
<xsl:if test="string(@display)">
<xsl:attribute name="displayValue">{<xsl:value-of select="@display"/>}</xsl:attribute>
<xsl:attribute name="uid">
<xsl:value-of select="$uid-assign"/>
<xsl:attribute name="xpath">{$newXpath}</xsl:attribute>
<xsl:attribute name="type">{$type}</xsl:attribute>
<xsl:copy-of select="@*|node()"/>

which can be handy for parameterization, shortening the syntax, etc.
(You will want to straighten up the indents in that code.)

I hope that helps.

Yup, it does. It's a bit more readable now.


Current Thread