Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - To get unique attributes [Thread Next] RE: To get unique attributesTo: NULL Date: 7/7/2004 12:36:00 AM Hi -
In your XML there appears to be <Class> elements that hold Percentage attributes, along with a single <Grade> element that also holds a Percentage attribute. I assume that this is intentional and not a cut-and-paste error.
I would use the following:
<xsl:variable name="unique-Percentage"
select="/School/Classes/Class/*[(self::Grade or self::Class) and @Percentage = '85']" />
This will generate a node-set containing all the <Class> or <Grade> elements that have a Percentage attribute equal to 85.
You shouldn't use //Class (a short-form of descendant-or-self::Class) because it's inefficient. You also can't use /School/Classes/Class because this will only consider the <Class> elements with the ClassId attribute.
Hope this helps.
- Tim
"DotNetJunkies User" wrote:
> Hi
>
> I have an xml that is as follows:
> <School SchoolId="1">
> <Classes>
> <Class ClassId="1">
> <Grade Section="A" Name="Robert" Percentage="85" />
> </Class>
> <Class ClassId="1">
> <Class Section="B" Name="Robert" Percentage="75" />
> <Class Section="B" Name="John" Percentage="80" />
> </Class>
> <Class ClassId="1">
> <Class Section="C" Name="Robert" Percentage="87" />
> <Class Section="C" Name="John" Percentage="85" />
> <Class Section="C" Name="Mary" Percentage="90" />
> </Class>
> </Classes>
> </School>
>
> How do I write an XSL to get the list of all students who scored 85 % (exact) ?
>
> I tried as follows:
>
> <xsl:variable name="unique-Percentage" select="//Class[not(Grade/@Percentage=preceding-sibling::Class/Grade/@Percentage)]"/>
>
> With the node-set I get in the variable unique-Percentage, using a for loop I tried to build another XML but I am unable to get unique output.
>
> Please help me regarding this.
>
>
> ---
> Posted using Wimdows.net NntpNews Component -
>
> Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
