Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Avoid multiple loops

From: "Praveen" <praveen@---------.------>
To: NULL
Date: 1/3/2006 8:59:00 AM
Im doing an xslt transform.
One of my xml element is like this
<Parent>
    <Items Atrr1="12" Atrr2="15" Atrr3="82"  Atrr4="15" Atrr5="12353" 
Atrr6="1452"/>
    <Items Atrr1="132" Atrr2="15" Atrr3="2"  Atrr4="14" Atrr5="1123" 
Atrr6="15452"/>
    <Items Atrr1="142" Atrr2="11" Atrr3="82"  Atrr4="31" Atrr5="1223" 
Atrr6="14552"/>
    <Items Atrr1="125" Atrr2="18" Atrr3="8"  Atrr4="11" Atrr5="12323" 
Atrr6="1352"/>
    <Items Atrr1="132" Atrr2="155" Atrr3="882"  Atrr4="112" Atrr5="1263" 
Atrr6="1252"/>
    <Items Atrr1="12" Atrr2="5" Atrr3="82"  Atrr4="16" Atrr5="3" 
Atrr6="15122"/>
    <Items Atrr1="1" Atrr2="15" Atrr3="8122"  Atrr4="112" Atrr5="3" 
Atrr6="13452"/>
    <Items Atrr1="12" Atrr2="175" Atrr3="82"  Atrr4="41" Atrr5="1223" 
Atrr6="15342"/>
</Parent>

Im trying to assign Items/@ value to different variable where Items/@Attr1 
is largest.

<xsl:variable name="Var1"><xsl:for-each select="Parent/Items"><xsl:sort 
select="Attr1" sort-order="descending"/>
<xsl:if test="position()=1"><xsl:value-of 
select="@Attr1"/></xsl:if></xsl:for-each></xsl:variable>

<xsl:variable name="Var2"><xsl:for-each select="Parent/Items"><xsl:sort 
select="Attr1" sort-order="descending"/>
<xsl:if test="position()=1"><xsl:value-of 
select="@Attr2"/></xsl:if></xsl:for-each></xsl:variable>
Like this I will be having 6 variables for all attributes.

I want to know is there any better way t o do this. Is it possible to get 
the Node of 'Items' whose @Attr1 is largest to a variable and use that 
variable to read all otehr attributes. How to avoind this multiple loops???


thanks
praveen 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent