Welcome to WebmasterWorld Guest from 54.146.248.111

Forum Moderators: httpwebwitch

Message Too Old, No Replies

Sorting XML document to create another one?

     

TooMuch2AM

4:36 pm on Jan 22, 2009 (gmt 0)

5+ Year Member



In need of some good advice on 'consolidating' an XML file into another using XSL folks. Hope you can help!

My souce XML looks like so:

<?xml version="1.0" encoding="utf-8"?>
<vehicles>
<make xmake="ALFA ROMEO">
<model xmodel="159 SPORTWAGON">
<derivative xderivative="3.2 V6 JTS Q4 Lusso 5dr" />
</model>
</make>
<make xmake="ALFA ROMEO">
<model xmodel="SPIDER CONVERTIBLE">
<derivative xderivative="3.2 V6 JTS Q4 2dr" />
</model>
</make>
<make xmake="ALFA ROMEO">
<model xmodel="SPIDER CONVERTIBLE">
<derivative xderivative="2.8 V6 Q4 2dr" />
</model>
</make>
<make xmake="CITROEN">
<model xmodel="C4 COUPE SPECIAL EDITIONS">
<derivative xderivative="1.6HDi 16V by LOEB 3dr" />
</model>
</make>
<make xmake="FORD">
<model xmodel="S-MAX DIESEL ESTATE">
<derivative xderivative="2.0 TDCi LX 5dr" />
</model>
</make>
</vehicles>

Basically I have several vehicles but need to group them by Make, Model and Derivative thus:

<vehicles>
<make name='ALFA ROMEO'>
<model name='159 SPORTWAGON'>
<Derivative>3.2 V6 JTS Q4 Lusso 5dr</Derivative>
</model>
<model name='SPIDER CONVERTIBLE'>
<Derivative>3.2 V6 JTS Q4 2dr</Derivative>
<Derivative>2.8 V6 Q4 2dr</Derivative>
</model>
</make>
<make name='CITROEN'>
<model name='C4 COUPE SPECIAL EDITIONS'>
<Derivative>1.6HDi 16V by LOEB 3dr</Derivative>
</model>
</make>
<make name='FORD'>
<model name='S-MAX DIESEL ESTATE'>
<Derivative>2.0 TDCi LX 5dr</Derivative>
</model>
</make>
</vehicles>

I'm pretty new to using XSL so any pointers towards how to acheive this would be gratefully received!

Many thanks!
TM2AM

[edited by: TooMuch2AM at 4:38 pm (utc) on Jan. 22, 2009]

ronburk

12:10 am on Jan 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tedious (as most XSLT programming is), but possible. Google for "grouping using the muenchian method" and see whether that clicks for you.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month