Subject: Re: [xsl] Positional Grouping From: Andy Carr1 <CARRA@xxxxxxxxxx> Date: Mon, 5 Mar 2007 17:12:19 +0000 |
Hey drkm Thanks for helping me with this. I have a couple of additional problems though, one is with the NumberedText the other is when a w:tbl element is at the same level as the w:p element but still needs to be a child of the Heading. When there is a numbered list, all the items in the list should be wrapped in an encompassing <List> tag like this <List> <ListItem>Item 1</ListItem> <ListItem>Item 2</ListItem> <ListItem>Item 3</ListItem> </List> I am currently getting <List> <ListItem>Item 1</ListItem> </List> <List> <ListItem>Item 2</ListItem> </List> <List> <ListItem>Item 3</ListItem> </List> I got this working with a test xml file using the following <xsl:template match="/"> <Body> <xsl:apply-templates /> </Body> </xsl:template> <xsl:template match w:body> <xsl:for-each-group select="w:p" group starting with="w:p[w:pPr/w:listPr/wx:t[@wx:val='1.']]" --- Groups by the list number when list num is 1 <List> <xsl:apply-templates select="current-group()" mode="List" /> </List> </xsl:for-each-group> </xsl:template> <xsl:template match="w:p" mode="List"> <ListItem> <xsl:value-of select="w:r/w:t"/> </ListItem> </xsl:template> This however wouldn't fit into the solution you provided. Do you know of a way that I could incorporate something like the above sample into your solution as your solution works really well and I don't want to change it unless absolutely necessary. The second problem is this: As you know the w:p tag is applied to all text entries in a Word document and when a table is created the w:tbl tag is applied at the same level. In a previous solution to my issue you had the w:tbl tag inserted with an "or" into the <xsl:for-each-group> statement which worked, but it doesn't appear to work in the current solution, although I may be getting the syntax wrong. The bold bits represent the changes I made .. Any more help would be greatly appreciated. <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[my:p-style(.) eq 'NumberedText']"> <List> <ListItem> <xsl:value-of select="w:r/w:t"/> </ListItem> </List> </xsl:template> <xsl:template match="w:tbl"> <Table> TABLE STRUCTURE IN HERE ... </Table> </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 or w:tbl" 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 Andy Andy Carr IT Specialist Tel: Internal - 298037 External - 01252 558037 Mail Point M1C IBM Application Services Meudon House, Meudon Avenue, Farnborough, GU14 7NB (Notes) Andy Carr1/UK/IBM@IBMGB (Internet)CARRA@xxxxxxxxxx Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: xsl-list Digest 28 Feb 20, Andy Carr1 | Thread | [xsl] how to reserve single space a, Lin, Jessica |
[xsl] Re: xsl-list Digest 28 Feb 20, Andy Carr1 | Date | [xsl] how to reserve single space a, Lin, Jessica |
Month |