Subject: RE: [xsl] Select elements between others From: "Michael Kay" <mhk@xxxxxxxxx> Date: Tue, 20 Jan 2004 12:48:58 -0000 |
A classic "positional grouping" problem: try a search for "XSLT positional grouping". In XSLT 2.0 this is easily handled using <xsl:for-each-group group-starting-at="block">. In 1.0, there are two main approaches: (a) apply-templates to the block elements; for each block element, apply-templates to the items related to that block, which you can select as following-sibling::item[generate-id(preceding-sibling::block[1]) = generate-id(current())] (b) treat it as a value-based grouping exercise, using Muenchian grouping with the generate-id of the block element as the grouping key. Michael Kay > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Joe Fawcett > Sent: 20 January 2004 09:29 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Select elements between others > > > I have received, what I consider to be, a badly designed xml > file: <data> > <block/> > <item>One</item> > <item>Two</item> > <block/> > <item>One</item> > <item>Two</item> > <item>Three</item> > <block/> > <item>One</item> > </data> > > I want to turn this into a more normal form to make it easier > to manage: > > <data> > <block> > <item>One</item> > <item>Two</item> > </block> > <block> > <item>One</item> > <item>Two</item> > <item>Three</item> > </block> > <block> > <item>One</item> > </block> > </data> > > Thanks > > Joe > > _________________________________________________________________ > Sign-up for a FREE BT Broadband connection today! > http://www.msn.co.uk/specials/btbroadband > > > 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] Select elements between o, George Cristian Bina | Thread | RE: [xsl] Select elements between o, Armen . Martirosyan |
RE: [xsl] converting escaped values, Jarno . Elovirta | Date | RE: [xsl] Get path of xsl template, Michael Kay |
Month |