I was developing an xsl that converts the input xml to other xml using XSLT as mentioned Below.
Logic: In the input xml, I mention four sub-elements "vehicle_No, vehicle_Model, Description, colour" in "Vehicle". I want to get a result " if "vehicle_No, vehicle_Model" matches with the next "vehicle" then the value in the "description" should become elements and then the output should look like..., Also Muenchian grouping for "Description" when "vehicle_No, vehicle_Model" matches,
Sample O/P: If Matched
<vehicle>
<car>
<color>BLACK</color>
<hood>RED</hood>
</car>
</vehicle>
If aren't Matched
<vehicle>
<car>
<color>BLACK</color>
<hood>RED</hood>
</car>
<cycle>
<color>violet</color>
</cycle>
</vehicle>
If in case i get a same value for "description" mentioned in input xml and "vehicle_No, vehicle_Model" aren't matches. Then the o/p should look like
<vehicle>
<car>
<color>BLACK</color>
<hood>RED</hood>
</car>
<cycle>
<color>violet</color>
</cycle>
</vehicle>
<vehicle>
<car>
<color>RED</color>
</car>
</vehicle>
My Input XML File:
<t>
<Vehicle>
<vehicle_No>123</vehicle_No>
<vehicle_Model>Audi</vehicle_Model>
<Description>car.color</Description>
<colour>BLACK</colour>
</Vehicle>
<Vehicle>
<vehicle_No>123</vehicle_No>
<vehicle_Model>Audi</vehicle_Model>
<Description>car.hood</Description>
<colour>RED</colour>
</Vehicle>
<Vehicle>
<vehicle_No>123</vehicle_No>
<vehicle_Model>BMW</vehicle_Model>
<Description>Bus.Brakes</Description>
<colour>steel</colour>
</Vehicle>
<Vehicle>
<vehicle_No>123</vehicle_No>
<vehicle_Model>BMW</vehicle_Model>
<Description>Bus.steering</Description>
<colour>black</colour>
</Vehicle>
<Vehicle>
<vehicle_No>234</vehicle_No>
<vehicle_Model>benz</vehicle_Model>
<Description>cycle.color</Description>
<colour>violet</colour>
</Vehicle>
<Vehicle>
<vehicle_No>345</vehicle_No>
<vehicle_Model>nissan</vehicle_Model>
<Description>car.color</Description>
<colour>RED</colour>
</Vehicle>
</t>
Expected Output in XML:
<t>
<Vehicle>
<car>
<color>BLACK</color>
<hood>RED</hood>
</car>
<Bus>
<Brakes>steel</Brakes>
<Steering>black</Steering>
</Bus>
<cycle>
<color>violet</color>
</cycle>
</Vehicle>
<vehicle>
<car>
<color>RED</color>
</car>
</vehicle>
</t>
Please let me know if Question was unclear.