RE: [xsl] Excluding certain nodes from xsl:number count

Subject: RE: [xsl] Excluding certain nodes from xsl:number count
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 16 May 2007 21:53:42 +0100
Use level="single" (the default) rather than level="any".

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Andy Carr1 [mailto:CARRA@xxxxxxxxxx] 
> Sent: 16 May 2007 18:18
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Excluding certain nodes from xsl:number count
> 
> Hi
> 
> I have a particular problem trying to exclude certain nodes 
> from being counted.
> 
> I am trying to implement paragraph numbering, but some 
> paragraphs (i.e the ones inside tables) should not be 
> numbered and therefore should not be included in the count.
> 
> For example, take this snippet of xml:
> 
> <Body>
> 
>    <Para> Some Text </Para>
>    <Para> Some Text </Para>
>    <Para> Some Text </Para>
>    <Para> Some Text </Para>
>    <Para> Some Text </Para>
> 
>    <Table>
>       <row>
>          <cell><Para>Table Text</Para></cell>
>          <cell><Para>Table Text</Para></cell>
>          <cell><Para>Table Text</Para></cell>
>       </row>
>    </Table>
> 
>    <Para> Some Text </Para>
>    <Para> Some Text </Para>
>    <Para> Some Text </Para>
>    <Para> Some Text </Para>
>    <Para> Some Text </Para>
> 
> </Body>
>  
> This kind of structure needs to be transformed to produce
> 
> 1. Some Text
> 2. Some Text
> 3. Some Text
> 4. Some Text
> 5. Some Text
> 
> Then the Table...
> 
> 6. Some Text
> 7. Some Text
> 8. Some Text
> 9. Some Text
> 10. Some Text
> 
> But what I am getting when I use 
>         <xsl:number from="Body" level="any" count="Para" 
> format="1." />
> 
> 1. Some Text
> 2. Some Text
> 3. Some Text
> 4. Some Text
> 5. Some Text
> 
> Then the Table...
> 
> 9. Some Text
> 10. Some Text
> 11. Some Text
> 12. Some Text
> 13. Some Text
> 
> What I need to do is exclude the Para nodes in the Table from 
> the count, but I can't figure out how.
> 
> Anybody? 
> 
> Regards
> Andy
> 
> Andy Carr
> Senior 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