Retreiving Parent Values by specifying a attribute value

P

pathisunil

Dear All

I have an xmldocument which is as formed below. It is a bit of loopy in
nature. can anyone kindly let me know how can i write a xslt which
would take a parameter which is an attribute value and would like to
have details out of the xml file.

I will the paste the xmldocument for your reference.The values required
as output are based on reverse pattern.The functionality requires this
pattern.The values required are as follows:

Required Output:Which happen to be as given below
cars/make = "alfa romeo"
cars/make/shortmodels/shortmodel = "147"
cars/make/shortmodels/shortmodel/longmodels/longmodel = "Distinctive"
cars/make/shortmodels/shortmodel/longmodels/longmodel/derivatives/derviate[@vehicle_id='14825420040501']
= "1.6 T.Spark Distinctive hatchback"

The above values which are in quotes must be returned after using an
xslt by giving the following attribute @vehicle_id='14825420040501

This particular xml file contains only 1 make, but in the original file
this make would be repeated in nature.

Example of the XML File.
<cars>
<make forsale="1">Alfa Romeo<shortmodels>
<shortmodel>147<longmodels>
<longmodel>Distinctive<derivatives>
<derivative vehicle_id="14825420040501">
<price>13936</price>
<co2>192</co2>
<fueltype>U</fueltype>1.6 T.Spark Distinctive
hatchback<colours/>
<trims/>
</derivative>
<derivative vehicle_id="14825520040501">
<price>14667</price>
<co2>194</co2>
<fueltype>U</fueltype>1.6 T.Spark Distinctive
hatchback<colours/>
<trims/>
</derivative>
</derivatives>
</longmodel>
<longmodel>Edizione Exclusiva<derivatives>
<derivative vehicle_id="69743420040501">
<price>14323</price>
<co2>192</co2>
<fueltype>U</fueltype>1.6 T.Spark Edizione Exclusiva
hatchback<colours/>
<trims/>
</derivative>
<derivative vehicle_id="69743620040501">
<price>15054</price>
<co2>194</co2>
<fueltype>U</fueltype>1.6 T.Spark Edizione Exclusiva
hatchback<colours/>
<trims/>
</derivative>
<derivative vehicle_id="69744120040501">
<price>14658</price>
<co2>192</co2>
<fueltype>U</fueltype>1.6 T.Spark Edizione Exclusiva
hatchback<colours/>
<trims/>
</derivative>
</derivatives>
</longmodel>
<longmodel>Edizione Sportiva<derivatives>
<derivative vehicle_id="69743320040501">
<price>12648</price>
<co2>192</co2>
<fueltype>U</fueltype>1.6 T.Spark Edizione Sportiva
hatchback<colours/>
<trims/>
</derivative>
<derivative vehicle_id="69743520040501">
<price>13348</price>
<co2>194</co2>
<fueltype>U</fueltype>1.6 T.Spark Edizione Sportiva
hatchback<colours/>
<trims/>
</derivative>
</derivatives>
</longmodel>
</longmodels>
</shortmodel>
<shortmodel>156<longmodels>
<longmodel>Distinctive<derivatives>
<derivative vehicle_id="69715520040501">
<price>17136</price>
<co2>195</co2>
<fueltype>U</fueltype>1.6 T.Spark 16V Distinctive
sedan<colours/>
<trims/>
</derivative>
<derivative vehicle_id="69715620040501">
<price>17703</price>
<co2>202</co2>
<fueltype>U</fueltype>1.8 T.Spark 16V Distinctive
sedan<colours/>
<trims/>
</derivative>
</derivatives>
</longmodel>
<longmodel>Edizione Esclusiva<derivatives>
<derivative vehicle_id="79524520040501">
<price>16750</price>
<co2>195</co2>
<fueltype>U</fueltype>1.6 T.Spark 16V Edizione Esclusiva
sedan<colours/>
<trims/>
</derivative>
<derivative vehicle_id="79510720040501">
<price>17316</price>
<co2>202</co2>
<fueltype>U</fueltype>1.8 T.Spark 16V Edizione Esclusiva
sedan<colours/>
<trims/>
</derivative>
</derivatives>
</longmodel>
</longmodels>
</shortmodel>
</shortmodels>
</make>
</cars>


Thanks in advance...

Regards
Sunil.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top