[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Getting max attribute value of an element by attri

Subject: Re: Getting max attribute value of an element by attribute value...
From: "cutlass" <cutlass@xxxxxxxxxxx>
Date: Wed, 28 Nov 2001 15:05:02 -0000
xquery max attribute value
try this



<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


 <xsl:template match="/">

 <xsl:variable name="test" select="//class"/>

<xsl:for-each select="/classes/class">
<xsl:sort select="@short"/>
<xsl:sort data-type="number" order="descending" />

<xsl:if test="not(@short = preceding::class/@short)">

 <xsl:value-of select="@short"/>(<xsl:value-of select="@level"/>)<xsl:if
test="not(position() = last())">, </xsl:if>

</xsl:if>
</xsl:for-each>


 </xsl:template>


</xsl:stylesheet>

cheers, jim fuller


----- Original Message -----
From: "Brinkman, Theodore" <Theodore.Brinkman@xxxxxxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, November 28, 2001 2:34 PM
Subject:  Getting max attribute value of an element by attribute
value...


> I have the following substructure in an XML file I'm working with.
>
> <classes>
> <class name="Fighter" short="Ftr" level="1" hp="10"
> uri="../class/fighter.xml"/>
> <class name="Rogue" short="Rog" level="1" hp="3"
> uri="../class/rogue.xml"/>
> <class name="Fighter" short="Ftr" level="2" hp="5"
> uri="../class/fighter.xml"/>
> </classes>
>
>
> I'm trying to get this as the output.
>
> Ftr(2), Rog(1)
>
>
> Currently, I can only figure out how to get this:
>
> Ftr(1), Rog(1), Ftr(2)
>
>
> The template I'm using currently stands as:
>
> <xsl:template name="listClasses">
> <xsl:for-each select="classes/class">
> <xsl:value-of select="@short"/>(<xsl:value-of
> select="@level"/>)<xsl:if test="not(position() = last())">, </xsl:if>
> </xsl:for-each>
> </xsl:template>
>
>
> How can I change the template to sort the <class>es so they are all
grouped
> with the first appearance of the class, and I only get the highest level
of
> the class inside the parenthesis?
>
> - Theo
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.