Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Help needed with transition [Thread Next] Re: Help needed with transitionTo: NULL Date: 11/19/2008 1:07:00 AM David has given both a 2.0 and a 1.0 solution. I wouldn't write anything different for what David wrote for XSLT 2.0. But here's a slightly different 1.0 solution, <xsl:stylesheet xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform" version=3D"1.0"> <xsl:output method=3D"xml" indent=3D"yes" /> <xsl:template match=3D"x"> <result> <xsl:apply-templates select=3D"field[heading]" mode=3D"a" /> </result> </xsl:template> <xsl:template match=3D"field" mode=3D"a"> <fieldset> <legend><xsl:value-of select=3D"heading" /></legend> <xsl:apply-templates select=3D"following-sibling::field[1][text]" mode=3D"b" /> </fieldset> </xsl:template> <xsl:template match=3D"field" mode=3D"b"> <p><xsl:value-of select=3D"text" /></p> <xsl:apply-templates select=3D"following-sibling::field[1][text]" mode=3D"b" /> </xsl:template> </xsl:stylesheet> this is popularly known as the sibling recursion technique. Cheers, Mukul On Nov 19, 2:40=A0am, "Hvid Hat" <hvid....@please-no-mail.thx> wrote: > Hi > > Can anyone help me with the following transition? My problem is how to cr= eate > a fieldset each time I run into a heading and then include the following = text > elements within the fieldset. > > <?xml version=3D"1.0" encoding=3D"ISO-8859-1"?> > <field> > =A0 <heading>First heading</heading> > </field> > <field> > =A0 <text>Lorem</text> > </field> > <field> > =A0 <text>Ipsum</text> > </field> > <field> > =A0 <heading>Second heading</heading> > </field> > <field> > =A0 <text>Dolor</text> > </field> > <field> > =A0 <text>Sit</text> > </field> > <field> > =A0 <heading>Third heading</heading> > </field> > <field> > =A0 <text>Amet</text> > </field> > > To > > <fieldset> > =A0 <legend>First heading</legend> > =A0 <p>Lorem</p> > =A0 <p>Ipsum</p> > </fieldset> > <fieldset> > =A0 <legend>Second heading</legend> > =A0 <p>Dolor</p> > =A0 <p>Sit</p> > </fieldset> > <fieldset> > =A0 <legend>Third heading</legend> > =A0 <p>Amet</p> > </fieldset> | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
