I have tried simple grouping XML with XSLT 1.0 and it worked, but here I have something more complicated and actually different situation. So the XML structure is basically this:
<Main>
<TB>
--> some elements and stuff - not relevant
<City>
<Area>
<Position>5</Position>
<House>
--> some elements and stuff
</House>
</Area>
<Area>
<Position>5</Position>
<Block>
--> some elements and stuff
</Block>
</Area>
<Area>
<Position>6</Position>
<House>
--> some elements and stuff
</House>
</Area>
<Area>
<Position>6</Position>
<Block>
--> some elements and stuff
</Block>
</Area>
</City>
<City>
--> same structure but with several repetitions of Position 7 and 8.
</City>
</TB>
</Main>
What I need is to group the Block
s and House
s which are under the same position and remove the repetition of Position numbers. For example it will get like this:
<City>
<Area>
<Position>5</Position>
<House>
--> some elements and stuff
</House>
<Block>
--> some elements and stuff
</Block>
</Area>
<Area>
<Position>6</Position>
<House>
--> some elements and stuff
</House>
<Block>
--> some elements and stuff
</Block>
</Area>
</City>
<City>
--> same structure for Position 7 and 8.
</City>
It's harder because the Position is not an attribute of the Area, so I basically have to identify the value of the Position of the Area, then grab the House and Block that fall under the same Position, and put them together surrounded by the same <Area> </Area>
.