Subject: Re: [xsl] Generating multi-level flexible recursive nested lists From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 6 Jun 2006 23:58:19 +0100 |
> If you see HTML view of my expected output, you will > know what I meant. but that your requested output is an html syntax error, if your browser displays anything it's just because browswers almost never give errors and try to handle any markup that looks a bit like html. An ol may only have li elements as children and you are requesting that it have nested ol elements. <ol> <li> ALevel1 </li> <li> BLevel1 </li> <ol> <li> aLevel2 </li> <li> bLevel2 </li> </ol> <li> CLevel1 </li> should be b <ol> <li> ALevel1 </li> <li> BLevel1 <ol> <li> aLevel2 </li> <li> bLevel2 </li> </ol> </li> <li> CLevel1 </li> David <xsl:template match="doc"> <html> <body> <xsl:apply-templates mode="ol" select="p[1]"/> </body> </html> </xsl:template> <xsl:template mode="ol" match="p"> <xsl:variable name="l" select="substring-after(@style,'level')"/> <ol> <li> <xsl:copy-of select="normalize-space(.)"/> <xsl:apply-templates mode="ol" select="following-sibling::p[1][substring-after(@style,'level') > $l]"/> </li> <xsl:apply-templates mode="li" select="following-sibling::p[substring-after(@style,'level') <= $l][1][substring-after(@style,'level') = $l]"/> </ol> </xsl:template> <xsl:template mode="li" match="p"> <xsl:variable name="l" select="substring-after(@style,'level')"/> <li> <xsl:copy-of select="normalize-space(.)"/> <xsl:apply-templates mode="ol" select="following-sibling::p[1][substring-after(@style,'level') > $l]"/> </li> <xsl:apply-templates mode="li" select="following-sibling::p[substring-after(@style,'level') <= $l][1][substring-after(@style,'level') = $l]"/> </xsl:template> </xsl:stylesheet> <doc> <p style="level1"> ALevel1 </p> <p style="level1"> BLevel1 </p> <p style="level2"> aLevel2 </p> <p style="level2"> bLevel2 </p> <p style="level1"> CLevel1 </p> <p style="level1"> DLevel1 </p> <p style="level2"> aLevel2 </p> <p style="level2"> bLevel2 </p> <p style="level3"> iLevel3 </p> <p style="level3"> iiLevel3 </p> <p style="level2"> cLevel2 </p> <p style="level1"> ELevel1 </p> </doc> $ saxon lev.xml lev.xsl <html> <body> <ol> <li>ALevel1</li> <li>BLevel1 <ol> <li>aLevel2</li> <li>bLevel2</li> </ol> </li> <li>CLevel1</li> <li>DLevel1 <ol> <li>aLevel2</li> <li>bLevel2 <ol> <li>iLevel3</li> <li>iiLevel3</li> </ol> </li> <li>cLevel2</li> </ol> </li> <li>ELevel1</li> </ol> </body> </html> ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Generating multi-level fl, Devang Patel | Thread | [xsl] Iterating over values in a ta, Neil Crofts |
Re: [xsl] Generating multi-level fl, Devang Patel | Date | RE: [xsl] Another supported langaug, Alan Boldock |
Month |