Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 20th, 2013, 06:56 AM
Registered User
 
Join Date: May 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to organize(group) nodes under a closed element - XSLT

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:

Code:
<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 Blocks and Houses which are under the same position and remove the repetition of Position numbers. For example it will get like this:

Code:
<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>.





Similar Threads
Thread Thread Starter Forum Replies Last Post
need to add adjacent element(with their child nodes) in to single in XSLT xsltstarter XSLT 8 June 6th, 2012 10:13 AM
bunches of nodes, how to group them to different group using the business rules JohnKiller XSLT 9 March 7th, 2012 02:42 PM
Count of distinct nodes in a group anarleti XSLT 3 June 30th, 2010 03:39 AM
How to encapsulate element nodes? vb89 XSLT 2 May 24th, 2010 11:20 AM
Trying to group child nodes aalbetski XSLT 3 November 18th, 2006 01:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.