Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - RE: Avoid multiple loops [Thread Next] Re: Avoid multiple loopsTo: NULL Date: 1/6/2006 10:48:00 AM thanks
it helps us
praveen
"AnthonyWJones" <AnthonyWJones@d...> wrote in message
news:22E8E97B-0ECC-409B-B4C7-D795C4F822B9@m......
> This may be a better solution. Rather than having multiple variables for
> each attribute it is probably better to store the Items node that has the
> maximum atrr1 value then the variable holding the node can be queried for
> the
> other atrr values as and when needed.
>
> Also it's better to move the code to retrieve the maximum atrr1 value to
> it's own template reducing the clutter in the main template.
>
> It's done like this:-
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" encoding="UTF-8" indent="yes" />
> <xsl:template match="/Parent">
> <xsl:variable name="maxAtrr1">
> <xsl:apply-templates select="." mode="getMaxAttr1" />
> </xsl:variable>
> <xsl:variable name="itemsMax" select="Items[@Atrr1=$maxAtrr1]" />
> <result a1="{$itemsMax/@Atrr1}" a2="{$itemsMax/@Atrr2}"
> a3="{$itemsMax/@Atrr3}" a4="{$itemsMax/@Atrr4}" a5="{$itemsMax/@Atrr5}"
> a6="{$itemsMax/@Atrr6}" />
> </xsl:template>
>
> <xsl:template match="Parent" mode="getMaxAttr1">
> <xsl:for-each select="Items">
> <xsl:sort select="@Atrr1" order="descending" data-type="number" />
> <xsl:if test="position()=1">
> <xsl:value-of select="@Atrr1"/>
> </xsl:if>
> </xsl:for-each>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
