Subject: Re: [xsl] generic grouping without nesting for-each-group? From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Wed, 28 Jul 2010 16:29:53 +0200 |
I'm trying to process some very flat XML which looks something like:
=== <body> <head level="1">one</head> <p>test</p> <p>test</p> <head level="3">two</head> <p>test</p> <p>test</p> <head level="2">three</head> <p>test</p> <p>test</p> </body> ===
(But for this case these could easily have been <h1> <h3> and <h2>)
What I want to do, predictably, is give nested structure to this using @level and get something like:
=== <body> <div> <head level="1>one</head> <p>test</p><p>test</p> <div> <div><head level="3">two</head> <p>test</p><p>test</p> </div> </div> <div> <head level="2">three</head> <p>test</p><p>test</p> </div> </div> </body> ==== (i.e. notice the extra blank encompassing div around the level 3 division.)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mf="http://example.com/mf" exclude-result-prefixes="xs mf" version="2.0">
<xsl:template match="body"> <xsl:copy> <xsl:sequence select="mf:group(*, 1, 0)"/> </xsl:copy> </xsl:template>
Martin Honnen http://msmvps.com/blogs/martin_honnen/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] generic grouping without , James Cummings | Thread | Re: [xsl] generic grouping without , James Cummings |
Re: [xsl] generic grouping without , James Cummings | Date | [xsl] fo:simple-page-master related, Red Light |
Month |