[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

grouping children of same name parents under one commo

Subject: grouping children of same name parents under one common tag
From: abickford@xxxxxxxxxx
Date: Thu, 19 Jun 2003 15:13:25 -0400 (EDT)
grouping children
Good afternoon.  I'm new to xsl, and need some advice on how to format a
document.  I'm looking to find all the tags with the same name, collect
their children and put them all under one common tag.  Part of the problem
is, I have no idea what the tag names will be.


Let's say the xml I want to transform looks like this:

<root>

  <bob>
    <someTag>content1</someTag>
  </bob>

  <bob>
    <someTag>content2</someTag>
  </bob>

  <sue>
    <someTag>content3</someTag>
  </sue>

  <warren>
    <someTag>content4</someTag>
  </warren>

  <warren>
    <someTag>content5</someTag>
  </warren>

</root>



I would like the output to be:



<root>

  <bob>
    <someTag>content1</someTag>
    <someTag>content2</someTag>
  </bob>

  <sue>
    <someTag>content3</someTag>
  </sue>

  <warren>
    <someTag>content4</someTag>
    <someTag>content5</someTag>
  </warren>

</root>


Again, I don't know the tag names ahead of time(Bob, Sue, and Warren are
just examples).  I'm not sure how to tell xsl that I want to:

1) compare the current node's name with its siblings' names.
2) if a name match is found, adopt the matched sibling's children. (matched
sibling can die now, how nice of me ;)
3) keep looking for more siblings with matching names, adopting their
children if more matches are found.
4) don't repeat steps 1-3 for matched siblings (not an issue if they were
killed in step 2 when their children were taken away).


Thanks for any help.  I'm having trouble accomplishing this, even tho I
know exactly what I want.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.