Re: [xsl] Nodeset problems (called RTF variable before)

Subject: Re: [xsl] Nodeset problems (called RTF variable before)
From: "Ragulf Pickaxe" <jawxml@xxxxxxxxxxx>
Date: Mon, 28 Oct 2002 12:16:08 +0000
Hello Joerg

I think you have to rethink your problem.

Well, I can't come up with another solution, which will be good :(


I am not very experienced using XSL, so I probably think in a way that is counterproductive to what I want. I will try to scetch the problem, and if anyone can come up with a better solution (broad details are enough, I think), I am all eager trying that out.

(I might be a little long in explaining)

I have a project which works, but I want to rework the solution.
Current solution is something like:
..
<td>
<xsl:choose>
<xsl:when test="$Cond_One='This' and $Cond_two='Us'">
<a href="FileA.asp?Param={$Param}" title="{$Language/This}">
<b><xsl:value-of select="$Language/A"/></b>
</a>
<a href="FileA.asp?Param={$Param}" title="{$Language/This}">
<img src="concat($ImageLocation, 'Something.gif')" width="15" height="9" border="0"/>
</a>
</xsl:when>
<xsl:when test="$Cond_One='This' and $Cond_two='Them'">
<a href="FileA.asp?Param={$Param}" title="{$Language/That}">
<b><xsl:value-of select="$Language/A"/></b>
</a>
<a href="FileA.asp?Param={$Param}" title="{$Language/That}">
<img src="concat($ImageLocation, 'Someother.gif')" width="15" height="9" border="0"/>
</a>
</xsl:when>
<xsl:otherwise>
<a href="FileA.asp?Param={$Param}" title="{$Language/This}">
<b><xsl:value-of select="$Language/A"/></b>
</a>
<img src="concat($ImageLocation, 'transparent.gif')" width="15" height="9"/>
</xsl:otherwise>
</xsl:choose>
</td><td>
<xsl:choose>
<xsl:when test="$Cond_One='That' and $Cond_two='Us'">
..
</xsl:choose>
</td><td>
.. (Lots more)


So, I send two parameters to the stylesheet - Cond_One and Cond_two. In all but one of the <xsl:choose> the default (<xsl:otherwise>) condition will be made (depending wholly on Cond_One) - the other one will, depending on Cond_two have either one or the other <xsl:when> expression parsed.

As this is very verbose, and because I now have to output it differently depending on a newly introduced third parameter (meaning twise as much code in the current solution), I wanted to put different strings in the afforementioned nodeset variable and then calling a template which have a parameter (Number - for example):

<xsl:template name="Output">
<xsl:param name="Numbertest" select="Number"/>
<xsl:for-each select="$test2">
<xsl:if test="$test2[pos()]!=$Numbertest">
<a href="{concat(current()/file, '?Param={$Param}')}" title="{$Language/This}">
<b><xsl:value-of select="Current()/name"/></b>
</a>
<img src="concat($ImageLocation, 'transparent.gif')" width="15" height="9"/>
</xsl:if>
</xsl:for-each>
</xsl:template>


Where the <xsl:variable> test2 contains rows of
<node><name>..</name><file>..</file></node>
in the right order. No problem with the <file> part, but the <name> must have the localised language, meaning I have to have it as an input from the Language file (-> $Language variable).
(I am not totally sure of the syntax of the concationation in the called template above).


If there is another way of doing something like this - cutting some pages of code into just 20 lines, I will be happy if such would be shared with me.


Sincerely Ragulf Pickaxe :)


_________________________________________________________________
Broadband? Dial-up? Get reliable MSN Internet Access. http://resourcecenter.msn.com/access/plans/default.asp



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread