|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Positional Grouping
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|







