Subject: Re: [xsl] Getting max attribute value of an element by attribute value... From: "cutlass" <cutlass@xxxxxxxxxxx> Date: Wed, 28 Nov 2001 15:05:02 -0000 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Getting max attribute value o, Brinkman, Theodore | Thread | Re: [xsl] Getting max attribute val, cutlass |
[xsl] Getting max attribute value o, Brinkman, Theodore | Date | Re: [xsl] Getting max attribute val, cutlass |
Month |