Subject: RE: [xsl] De-flattening an XML tree From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Wed, 9 Jan 2002 10:06:27 -0000 |
This is a problem I call "positional grouping". One way to tackle it is to reduce it to a value-based grouping problem, where the grouping key for a <record> is it's generate-id(), and for a <data> element is generate-id(preceding-sibling::record[1]). Then you can use standard Muenchian grouping as described in http://www.jenitennison.com/xslt/grouping. Alternatively, if this is a one-off, why not try the new XSLT 2.0 grouping facilities available in Saxon 7.0? <xsl:for-each-group group-starting-at="record"> <record> <xsl:for-each select="current-group()[self::data]"> <xsl:copy-of select="."/> </xsl:for-each> </record> </xsl:for-each> Mike Kay > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Benjamin > Johnston > Sent: 09 January 2002 01:25 > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > Cc: Benjamin Johnston > Subject: [xsl] De-flattening an XML tree > > > > Hi, > > I'm kind of stuck on ideas for how I might de-flatten a tree. It seems > that I can't get the position of the next sibling with some > property and I > end up going around in circles with checking siblings because filter > predicates seem to only work with one node at a time. > > If I've got something like; > > <recordset> > <record/> > <data/> > <data/> > <record/> > <data/> > <record/> > <data/> > <data/> > <data/> > </recordset> > > ie. we've got a record tag, followed by it's "children". > > Is there any way of transforming this to: > <recordset> > <record> > <data/> > <data/> > </record> > <record> > <data/> > </record> > <record> > <data/> > <data/> > <data/> > </record> > </recordset> > > > Any suggestions, ideas or strategies? > > Thanks a lot! > > -Benjamin Johnston > s355171@xxxxxxxxxxxxxxxxx > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] De-flattening an XML tree, Joerg . Heinicke | Thread | [xsl] counting question, Jo Bourne |
RE: [xsl] performance with XSLT, Michael Kay | Date | RE: [xsl] Value of next node, Michael Kay |
Month |