Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Element Counting

Reply
Thread Tools

Element Counting

 
 
BakedBean
Guest
Posts: n/a
 
      07-19-2005
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

 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      07-19-2005

It's probably easiest to use

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

David
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
The element 'compilation' has invalid child element 'compilers'. =?Utf-8?B?Um9iZXJ0?= ASP .Net 3 11-15-2005 01:48 AM
counting up instead of counting down edwardfredriks Javascript 6 09-07-2005 03:30 PM
moving from form element to form element Rod Snyder ASP .Net 1 05-29-2004 01:55 PM
per the active schema, the element <BR> must be included within a parent element MSNews ASP .Net 1 04-22-2004 04:45 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57