Subject: Re: [xsl] Positional Grouping From: Florent Georges <darkman_spam@xxxxxxxx> Date: Wed, 28 Feb 2007 00:42:42 +0100 (CET) |
Andy Carr1 wrote: Hi I think you didn't get a response yet. > I now find that I need to have sections-within-sections > and I can't get it to work.. Instead of grouping on one level, directly in the template rule for ns0:Body, you can call a recursive grouping named template: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns0="ns0" xmlns:w="w" xmlns:my="my:andy-2.xsl" exclude-result-prefixes="my ns0 w xs" version="2.0"> <xsl:output indent="yes"/> <xsl:function name="my:p-style" as="xs:string"> <xsl:param name="p" as="element()"/> <xsl:sequence select="$p/w:pPr/w:pStyle/@w:val"/> </xsl:function> <xsl:template match="ns0:Body"> <Body> <xsl:call-template name="my:grouping"> <xsl:with-param name="p" select="w:p"/> <xsl:with-param name="level" select="1"/> </xsl:call-template> </Body> </xsl:template> <xsl:template match="w:p[matches(my:p-style(.), 'Heading[0-9]')]"> <Title> <xsl:value-of select="w:r/w:t"/> </Title> </xsl:template> <xsl:template match="w:p[my:p-style(.) eq 'NumberedText']"> <List> <ListItem> <xsl:value-of select="w:r/w:t"/> </ListItem> </List> </xsl:template> <xsl:template match="w:p[my:p-style(.) eq 'Text']"> <Para> <xsl:value-of select="w:r/w:t"/> </Para> </xsl:template> <xsl:template name="my:grouping"> <xsl:param name="p" as="element(w:p)+"/> <xsl:param name="level" as="xs:integer"/> <xsl:for-each-group select="$p" group-starting-with="w:p[my:p-style(.) eq concat('Heading', $level)]"> <xsl:choose> <xsl:when test="my:p-style(.) eq concat('Heading', $level)"> <Section> <xsl:call-template name="my:grouping"> <xsl:with-param name="p" select="current-group()"/> <xsl:with-param name="level" select="$level + 1"/> </xsl:call-template> </Section> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="current-group()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </xsl:template> </xsl:stylesheet> Regards, --drkm ___________________________________________________________________________ Dicouvrez une nouvelle fagon d'obtenir des riponses ` toutes vos questions ! Profitez des connaissances, des opinions et des expiriences des internautes sur Yahoo! Questions/Riponses http://fr.answers.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Positional Grouping, Andy Carr1 | Thread | [xsl] finding the last element with, Robert Walpole |
Re: [xsl] How to use generate-id() , Abel Braaksma | Date | RE: [xsl] How to use generate-id() , Michael Kay |
Month |