[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Excluding certain nodes from xsl:number count

Subject: Re: Excluding certain nodes from xsl:number count
From: George Cristian Bina <george@xxxxxxxxxxxxx>
Date: Thu, 17 May 2007 00:15:29 +0300
Re:  Excluding certain nodes from xsl:number count
Hi Andy,

Then count only Para that do not have Table as ancestor. For instance the following stylesheet should produce something like your expected result:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Table">Then the table...</xsl:template>
<xsl:template match="Para[not(ancestor::Table)]">
<xsl:number from="/Body" level="any" count="Para[not(ancestor::Table)]" format="1."/>
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>


Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Andy Carr1 wrote:
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.