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

RE: grouping children of same name parents under one c

Subject: RE: grouping children of same name parents under one common tag
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Thu, 19 Jun 2003 14:47:44 -0500
grouping children
This is a grouping problem.
http://www.jenitennison.com/xslt/grouping/index.html
and
http://www.dpawson.co.uk/xsl/sect2/N4486.html
will have some helpful pointers.

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

"local-name(.) = local-name(follow-sibling::*[1])", for example.
But what you probably want is a key on "local-name(.)".

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

You won't be modifying the source tree, so don't think of it in
terms of one node adopting another's children and another dying.

Rather, you will be outputting one node with the same name
as a set of input nodes (you could do this by using xsl:copy
on the first input node with a particular name) and then
copying all the children of the input node set as children
of your output node (using xsl:copy-of).

> 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).

This is where standard grouping techniques come in -- how to
eliminate the duplicates.  See the links above.

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

Indeed, you stated the problem like you know what you're talking
about.  It's just a matter of learning how this is done in XSLT.

Lars


 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.