Element Counting

Discussion in 'XML' started by BakedBean, Jul 19, 2005.

  1. BakedBean

    BakedBean Guest

    Hi,

    Hoping someone can help with this as it's been driving me round the
    bend! I have the following setup in XML:

    <unit>
    <title/>
    <section>
    <title/>
    <subsection>
    <content/>
    </subsection>
    </section>
    <section>
    <title/>
    <content/>
    <subsection>
    <content/>
    </subsection>
    </section>
    </unit>

    What I am trying to do is to put a page count (e.g. Page 1 of 147) on
    each html page that is produced. However, the issue is that the section
    will only have a corresponding html page, if there isn't a subsection
    in position() = 2. I have managed to calculate the total number of
    pages and then minused the number of sections that don't have
    corresponding html pages, but I can't get the page number as it goes
    along. I tried:

    <xsl:value-of
    select="count(*[name(parent::section/preceding-sibling::section[1]/*[position()
    = 2]) = 'subsection'])"/>

    and a whole number of other ideas, which didn't work! Has anyone got
    any ideas as I'm plain out. . .

    Cheers
    BakedBean, Jul 19, 2005
    #1
    1. Advertising

  2. It's probably easiest to use

    <xsl:number level ="any" count="section[not(*[2][self::subsection])]|subsection"/>

    David
    David Carlisle, Jul 19, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MSNews
    Replies:
    1
    Views:
    2,720
    Alvin Bruney [MVP]
    Apr 22, 2004
  2. Rod  Snyder

    moving from form element to form element

    Rod Snyder, May 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    404
    Vidar Petursson
    May 29, 2004
  3. =?Utf-8?B?Um9iZXJ0?=
    Replies:
    3
    Views:
    6,842
    Steven Cheng[MSFT]
    Nov 15, 2005
  4. HANM
    Replies:
    2
    Views:
    706
    Joseph Kesselman
    Jan 29, 2008
  5. edwardfredriks

    counting up instead of counting down

    edwardfredriks, Sep 6, 2005, in forum: Javascript
    Replies:
    6
    Views:
    196
    Dr John Stockton
    Sep 7, 2005
Loading...

Share This Page