Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Sorting and grouping with XSL Stylesheets

Reply
Thread Tools

Sorting and grouping with XSL Stylesheets

 
 
Jack Wayne
Guest
Posts: n/a
 
      01-24-2005
Hi,
I am using MSXML 3.0rc.

I have a document similar to the following:

<?xml version="1.0"?>
<cars>
<car name="Mercedes">
<model built="1985" style="Sedan">560 SEL</model>
<model built="1979" style="Coupe">520 SLC</model>
</car>
<car name="Dodge">
<model built="2004" style="Wagon">Magnum</model>
<model built="2004" style="Sedan">300</model>
</car>
<car name="Chevrolet">
<model built="2005" style="Sedan">Malibu</model>
<model built="2004" style="Sedan">Malibu</model>
<model built="2003" style="Sedan">Malibu</model>
</car>
<car name="BMW">
<model built="2005" style="Hatchback">Mini</model>
<model built="2005" style="Coupe">315i</model>
<model built="2005" style="Coupe">Z4</model>
</car>
<car name="Cadillac">
<model built="2004" style="SUV">Escalade</model>
<model built="2004" style="Sedan">STS</model>
<model built="2004" style="Sedan">CTS</model>
<model built="1981" style="Coupe">Coupe DeVille</model>
</car>
</cars>

And I would like to produce the following: note that /model of the
same /car@name with the same ( /model/@built and /model/@style ) are
contained in the same <div> and the div are in order of /car/@name,
this needs to be created in an xsl stylesheet, the sorting I can do
but haven't figured out how to group the similar items together.

Any assistance would be most appreciated

Thanks Jack

<div>
<table>
<tr>
<td>BMW - 2005 - Coupe </td>
</tr>
<tr>
<td>315i, Z4</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>BMW - 2005 - Hatchback</td>
</tr>
<tr>
<td>Mini</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>Cadillac - 2004 - SUV</td>
</tr>
<tr>
<td>Escalade</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>Cadillac - 2004 - Sedan</td>
</tr>
<tr>
<td>CTS, STS</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>Cadillac - 1981 - Coupe</td>
</tr>
<tr>
<td>Copupe DeVille</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>Chevrolet - 2004 - Sedan</td>
</tr>
<tr>
<td>Malibu</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>Chevrolet - 2003 - Sedan</td>
</tr>
<tr>
<td>Malibu</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>Chevrolet - 2002 - Sedan</td>
</tr>
<tr>
<td>Malibu</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>Dodge - 2004 - Wagon</td>
</tr>
<tr>
<td>Magnum</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>Dodge - 2004 - Sedan</td>
</tr>
<tr>
<td>300</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>Mercedes - 1985 - Sedan</td>
</tr>
<tr>
<td>560 SEL</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td>Mercedes - 1979 - Coupe</td>
</tr>
<tr>
<td>520 SLC</td>
</tr>
</table>
</div>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to embed xsl-stylesheets in resx-files? Andreas Zita ASP .Net 1 01-06-2006 01:33 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
sorting <xsl:for-each> versus <xsl:apply-templates> Sparko XML 0 07-09-2004 09:03 AM
XSLT: sorting and grouping Christian Ludwig XML 2 11-26-2003 10:37 AM
Re: XSL: grouping data and group header? Frank-Ralph Reiser XML 0 07-31-2003 07:53 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57