[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xml to xml transform
Shimon Pozin wrote: > Thanks, Mike, for the clue. However, when I tested > this solution, I paid attention that if the source > xml is slightly different: > <rows> > <row fld="f1" value="v1"/> > <row fld="f1" value="v2"/> > <row fld="f2" value="v3"/> > <row fld="f1" value="v2"/> > <row fld="f3" value="v4"/> > </rows> > > then this solution will not work since f1 comes after f2 > and in this case I'll see two elements f1 rather than one. With that XML and my stylesheet, I get the following result, which is exactly what you wanted: <?xml version="1.0" encoding="utf-8"?> <f1> <v1/> <v2/> <v2/> </f1> <f2> <v3/> </f2> <f3> <v4/> </f3> > Should I sort the entire collection before I use this > solution? Can I use sorting capabilities of apply-templates > for that? xsl:sort only affects the order in which nodes are processed; it doesn't rearrange the source tree. It wouldn't be useful here. I suspect your problem rests in the code you sent in private mail, in which you applied the solution in a manner that resulted in every row being processed, meaning the grouping was done (row) number of times. - Mike ____________________________________________________________________ Mike J. Brown, software engineer at My XML/XSL resources: webb.net in Denver, Colorado, USA http://skew.org/xml/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|