Element Counting

B

BakedBean

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
 
D

David Carlisle

It's probably easiest to use

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

David
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top